Hook.Channel.WEBSOCKETS Class
Item Index
Methods
Methods
call
(
Promise
-
procedure
Parameters:
-
procedure
String
Returns:
Promise:
disconnect
()
Hook.Channel
Disconnect from channel, publishing a 'disconnected' message.
Returns:
Hook.Channel:
this
isConnected
()
Boolean
Is EventSource listenning to messages?
Returns:
Boolean:
publish
(
Hook.Channel
-
event
-
message
-
options
Publish event message
Parameters:
-
event
String -
message
Object -
options
Object'exclude' and 'elegible' are optional options.
Returns:
Hook.Channel:
subscribe
(
Hook.Channel
-
event
-
callback
Subscribe to channel. Publishes a 'connected' message on the first time.
Parameters:
-
event
String(optional)
-
callback
Function
Returns:
Hook.Channel:
Example:
Registering for a single custom event
channel.subscribe('some-event', function(data) {
console.log("Custom event triggered: ", data);
})
Registering for client connected/disconnected events
channel.subscribe('connected', function(data) {
console.log("New client connected: ", data.client_id);
});
channel.subscribe('disconnected', function(data) {
console.log("Client disconnected: ", data.client_id);
});
unsubscribe
(
Hook.Channel
-
event
Unsubscribe to a event listener
Parameters:
-
event
String
Returns:
Hook.Channel: