This repository has been archived by the owner on Nov 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Handle Socket
Dmitrii Goriunov edited this page Dec 28, 2017
·
8 revisions
ClusterWS JavaScript Client provide an easy interface to communicate with ClusterWS server.
To listen on events which are send from server you should use on
method:
...
socket.on('my-event-name', (data) => {
// your code to execute on event
})
...
ClusterWS JavaScript Client reserved events:
...
// executed when client is connected to the server
socket.on('connect', () => {
// your code to execute on event
})
// executed when some error has happened
socket.on('error', (error) => {
// your code to execute on event
})
// executed when client is disconnected from the server
socket.on('disconnect', (code, reason) => {
// your code to execute on event
})
...
To send message to the server you should use send
method:
...
// data can be anything you want
socket.send('my-event-name', data)
...
Try to do not send events which starts with #
or reserved disconnect
, connection
, error
events.
💥 We would really appreciate if you give us stars ⭐ (on all our repositories):
For you to give the stars ⭐ is not hard, but for us, it is a huge motivation to work harder and improve the project. Thank you very much 😄.
1. Home
2. Installation and Configuration
5. Client to Client Communication
Other languages will be added later