- WebSockets Tutorial
- HTML5 WebSocket
- Create a WebSocket Server Using Node.js
- WebSocket : Simple client and Server
- ws: a Node.js WebSocket library
- WebSocket + Node.js + Express — Step by step tutorial using Typescript
- [Node.js] set up Websocket + Express + HTML service in 3 step
- Create a WebSocket Client in JavaScript
- 安装 python
- 下载 python2.7
- 安装
- 配置系统环境变量,添加两个路径到 Path
- absolute_path\Python27\Scripts
- absolute_path\Python27
- 测试:打开命令提示符,输入
python
,输出Python 2.7.15......
- 安装 pywebsocket
- 克隆源码
git clone https://github.com/google/pywebsocket.git
- 进入 pywebsocket 目录,执行命令
python setup.py build
python setup.py install
- 克隆源码
- 开启服务
python standalone.py -p 9998 -w ../example/
- 以上命令会开启一个端口号为 9998 的服务,使用 -w 来设置处理程序 echo_wsh.py 所在的目录
- 可以在浏览器打开index.html,连接的 url 写
ws://localhost:9998/echo
- pywebsocket 会把收到的消息再发送给 client
- 编写 server 和 client 代码,使用 websocket 通信
- 安装
ws
模块:npm install ws
- 创建文件夹
server/scripts
和server/pages
server/scripts
中编写app.jsserver/pages
中编写client.html
- 开启服务:在命令行打开app.js
node ./app.js
- 在浏览器打开客戶端代码