mixins/socket

SocketMixin

mixin SocketMixin(socketContext)

Mixin that provides websocket functionality.

Arguments:
  • socketContext (String) – See SocketProxy.socketContext.
read-onlysocket
Type:SocketProxy

The contained socket proxy instance.

SocketProxy

class SocketProxy(socketContext)

Warning

This class is not exportet and its instances are only available throug the implementers of the SocketMixin().

A lightweight socket proxy implementation that basically yields the emitter-like emit() and on() methods. Internally, these calls are forwarded to the global vispa.socket instance with socketContext being prefixed to all events.

Arguments:
read-onlysocketContext
Type:String

The socket context which is used to as a prefix for all events.

emit(event, ...)

Emits an event with all supplied arguments.

Arguments:
  • event (String) – The name of the event to emit to.
on(event, callback)

Listens to an event with a callback.

Arguments:
  • event (String) – The name of the event to listen to.
  • callback (Function) – The callback function that is invoked with all arguments supplied in the corresponding event emission.