websocket示例
| 回声服务器
cargo run server --release
启动Firefox Web控制台
const ws = new WebSocket('ws://localhost:8080/echo/');
ws.onmessage = function(message) {
console.log(message.data);
}
ws.onclose = function(message) {
console.log("Code:", message.code);
console.log("Reason:", message.reason);
console.log("Clean:", message.wasClean);
}
ws.send('hi!');
ws.close(1000, 'bye!');
2021-03-14 10:06:12
4KB
Rust
1