Constructor
new JsonMessagesProtocol(namedAs)
Arguments:
-
namedAs
(String)
 The name of a resulting protocol
Extends
Methods
sendCommand(command, recipient, params) → Boolean
Send a specified command to recipient. Return true
if data is sended (no guaranty it is recived by client)
Arguments:
-
command
(String)
 Command to send
-
recipient
(Number)
 User Session identifier
-
params
(*)
 Any value
getUserSessions(userID) → Array:.<Number:>
Returns the IDs of all the sessions with established WebSocket connections
Arguments:
-
userID
(Number)
 User identifier (from uba_user)
broadcast(command, params)
Send a specified command to all user sessions connected using this protocol
Arguments:
-
command
(String)
 Command to send
-
params
(*)
 Any value
setMaxListeners(n)
Obviously not all Emitters should be limited to 10. This function allows
that to be increased. Set to zero for unlimited.
Arguments:
-
n
(Number)
getMaxListeners() → Number
emit(type, …eventArgs) → boolean
Execute each of the listeners in order with the supplied arguments.
Returns true if event had listeners, false otherwise.
Arguments:
-
type
(String)
 Event name
-
...eventArgs
(*)
 Arguments, passed to listeners
addListener(type, listener) → EventEmitter
Adds a listener to the end of the listeners array for the specified event.
Will emit newListener
event on success.
Usage sample:
Session.on('login', function () {
console.log('someone connected!');
});
Returns emitter, so calls can be chained.
Arguments:
on(type, listener) → EventEmitter
Alias for addListener
Arguments:
once(type, listener) → EventEmitter
Adds a one time listener for the event. This listener is invoked only the next time the event is fired, after which it is removed.
Arguments:
removeListener(type, listener)
Remove a listener from the listener array for the specified event.
Caution: changes array indices in the listener array behind the listener.
Emits a 'removeListener' event if the listener was removed.
Arguments:
removeAllListeners(type) → EventEmitter
Removes all listeners, or those of the specified event.
It's not a good idea to remove listeners that were added elsewhere in the code,
especially when it's on an emitter that you didn't create (e.g. sockets or file streams).
Returns emitter, so calls can be chained.
Arguments:
-
type
(String)
 Event name
listeners(type) → Array:.<function()>
Returns an array of listeners for the specified event.
Arguments:
-
type
(String)
 Event name
true
if data is sended (no guaranty it is recived by client)
command
(String)
 Command to send
recipient
(Number)
 User Session identifier
params
(*)
 Any value
userID
(Number)
 User identifier (from uba_user)
command
(String)
 Command to send
params
(*)
 Any value
n
(Number)
type
(String)
 Event name
...eventArgs
(*)
 Arguments, passed to listeners
newListener
event on success.
Usage sample:
Session.on('login', function () {
console.log('someone connected!');
});
Returns emitter, so calls can be chained.
addListener
Returns emitter, so calls can be chained.
type
(String)
 Event name
type
(String)
 Event name