-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathSocket.io Notes
More file actions
26 lines (14 loc) · 940 Bytes
/
Socket.io Notes
File metadata and controls
26 lines (14 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Socket.io Notes
Socket.io is a library for implementing web sockets. Web sockets allow real time communication by leaving an open channel to communicate data between the client and server.
Server:
io.emit() sends data to all clients.
socket.emit() sends data just to the client that made the current connection.
socket.send() sends data just to the client that made the current connection and using a default message name of 'message' without allowing for custom message names.
socket.broadcast.emit() sends data to all clients except the one involved in the current connection.
socket.broadcast.send() ????
socket.on() receives a message from a client with the given message name.
Client:
Have to include script: <script src='/socket.io/socket.io.js'></script>
Start connection with: var socket = io();
socket.emit() sends data to the server.
socket.on() receives a message from the server with the given message name.