OpenVeo server API for plugins

API Docs for: 7.0.0
Show:

Pilot

Module: socket

Summary

Defines a base pilot for all pilots.

A Pilot is designed to interact with sockets' clients. It listens to sockets' messages by listening to its associated client emitter. It sends information to sockets' clients using its associated socket namespace.

A Pilot keeps a list of connected clients with associated sockets.

Constructor

Pilot

Syntax

Pilot

(
  • clientEmitter
  • namespace
)

Summary

Parameters:

Methods

addClient

Syntax

addClient

(
  • id
  • socket
)

Summary

Adds a client to the list of connected clients.

Parameters:

  • id String

    The client's id

  • socket Socket

    The client's associated socket

emitMessageAsIs

Syntax

emitMessageAsIs

(
  • name
  • [args]
)

Summary

Emits a message.

Alias of events.EventEmitter.emit method.

Parameters:

  • name String

    The event's name

  • [args] Mixed optional multiple

    Any number of arguments

Example:

this.emitMessageAsIs('message', 'value1', 'value2');

// is equivalent to :
this.emit('message', 'value1', 'value2');

emitMessageWithId

Syntax

emitMessageWithId

(
  • [args]
  • socket
  • callback
)

Summary

Emits a message replacing socket by the associated client's id.

Parameters:

  • [args] Mixed optional multiple

    Any number of arguments

  • socket Socket

    The socket

  • callback Function

    The function to call to respond to the client

Example:

this.emitMessageWithId('message', 'value1', socket, callback);

// is equivalent to :
this.emit('message', 'value1', socket.id, callback);

getClient

Syntax

getClient

(
  • id
)
Object | Null

Summary

Gets a connected client by its id.

Parameters:

Returns:

Object | Null:

The client or null if not found

getClientBySocketId

Syntax

getClientBySocketId

(
  • socketId
)
Object | Null

Summary

Gets a client by its associated socket id in the list of connected clients.

Parameters:

  • socketId String

    The socket id

Returns:

Object | Null:

The client or null if not found

removeClientBySocketId

Syntax

removeClientBySocketId

(
  • id
)
Object | Null

Summary

Removes a client, by its associated socket id, from the list of connected clients.

Parameters:

Returns:

Object | Null:

The removed client or null if not found

Properties

clientEmitter

Syntax

clientEmitter

AdvancedEmitter final

Summary

The emitter to receive sockets' messages from clients.

clients

Syntax

clients

Array final

Summary

The list of actually connected clients.

namespace

Syntax

namespace

SocketNamespace final

Summary

The sockets' namespace to communicate with clients.