Skip to content

Module: Socket: Network

Аниса edited this page Aug 5, 2022 · 2 revisions

━ Methods

━ socket.createNetwork() (Shared)

@Objective: Creates a network instance on socket.
const bool: state = cSocket.createNetwork(
  string: name, // Name of the network
  bool: isCallback // (Optional) Determines whether the network is a callback network
)

━ socket.destroyNetwork() (Shared)

@Objective: Destroys an existing network from socket.
const bool: state = cSocket.destroyNetwork(
  string: name
)

━ socket.isNetwork() (Shared)

@Objective: Validates socket's network.
const bool: state = cSocket.isNetwork(
  string: name
)

━ socket.fetchNetworks() (Shared)

@Objective: Retrieves an array of existing networks on socket.
const array: result = cSocket.fetchNetworks()

━ socket.on() (Shared)

@Objective: Attaches an handler to specified network.
⚠️ Callback networks can have only one handler unlike others.
const bool: state = cSocket.on(
  string: name,
  function: exec
)

━ socket.off() (Shared)

@Objective: Detaches an handler from specified network.
const bool: state = cSocket.off(
  string: name,
  function: exec
)

━ socket.emit() (Shared)

@Objective: Emits to non callback network.
// Client Syntax:
const bool: state = cSocket.emit(
  string: name,
  bool: isRemote, // (Optional): If left unspecified, emit will be handled locally
  ~: ...arguments
)

// Server Syntax:
const bool: state = cSocket.emit(
  string: name,
  socket: isRemote, // (Optional): If left unspecified, emit will be handled locally
  ~: ...arguments
)

━ socket.emitCallback() (Shared)

@Objective: Emits to callback network & awaits for result.
// Client Syntax:
const ~: result = cSocket.emitCallback(
  string: name,
  bool: isRemote, // (Optional): If left unspecified, emit will be handled locally
  ~: ...arguments
)

// Server Syntax:
const ~: result = cSocket.emitCallback(
  string: name,
  socket: isRemote, // (Optional): If left unspecified, emit will be handled locally
  ~: ...arguments
)