-
Notifications
You must be signed in to change notification settings - Fork 0
/
Socket.IO tips
36 lines (29 loc) · 1.04 KB
/
Socket.IO tips
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
27
28
29
30
31
32
33
34
35
36
excellent tutorial:
https://socket.io/get-started/chat/
$ means from command window
<!-- --> means comment
put package.json, index.js, index.html (view the code in index.txt) in the same folder, open command window, navigate to that folder (for example $ cd lickyvi/Desktop/SocketIOtips)
<!--install node.js, npm-->
https://nodejs.org/en/ > get LTS version
<!--install node.js express + dependencies-->
$ cd lickyvi/Desktop/SocketIOtips
$ npm install --save [email protected]
(result: node_modules, package-lock.json, express added to package.json)
<!--install server socket.io-->
$npm install --save socket.io
(result: socket.io added to package.json)
<!--index.html handles client in browser, index.js prints to command window-->
<!--run server-->
$node index.js
<!--connect client-->
(browser)
http://localhost:3000
<!--exit server-->
CTRL-C
<!--command window tracks open browser/tab, close/refresh, sent messages
all browser tabs display messages sent-->
$node index.js
(browser)
http://localhost:3000 or refresh current
(new browser tab)
http://localhost:3000