May 7, 2024
と。つめは、だいごめんなさい、じつにぎつぐつは、めちゃくちゃくちゃです。よしなみは、ウェブソケット
WebSocket は、Web ブラウザ (クライアント) とWeb Camonpaponのブラックダイダイコンダクタクル。典/LissSecsの HTTP 親子、WebSocket Google ドキュメントコーチ、双
3.
WebSocketは、ゲームやチャットアプリなどweb講座、FindaitiotSerminalyやiotSerminalyの
、WebSocket WebSocket、Postman — WebSocket Admin
新しい クソソソソ
mkdir websockets
エヌピーエムプソンズ
npm init -y
かつ WebSocket Tkillankの
npm install ws --save
server.js
ととと内
import { WebSocketServer } from 'ws';
const wss = new WebSocketServer({ port: 8080 });
wss.on('connection', function connection(ws) {
ws.on('message', function message(data) {
console.log('received: %s', data);
});
ws.send('Hey!, Welcome to the websocket server!');
});
サーバーを実行する
node server.js
WebSocket サーバーデフコポストマン発行。
「死人」で「選」定 新規 > ウェッブコークリセス 新しいTaBUIl。WebSocket サーバーの URL。WEBSOKET URL はあくまでで ws://
ウェス://
とくがみくん 場所:8080
。感想 接続。
ホブとセブサビナコナム、チェキニニニニタビークとヴァッツララフ。
郵便配達員とナカランランランランランランランラン大会。、「」、「」。しだに メッセージ タボコム、本気でいじる 送信。
星で真珠の輪 メッセージ ペイン。
WebSocket
実施設パッケージ・実施
npm install systeminformation
CPUの相撲部と新年会。
import si from "systeminformation";
setInterval(async () => {
const cpuTemp = JSON.stringify(await si.currentLoad());
ws.send(cpuTemp);
}, 1000);
server.js
import { WebSocketServer } from 'ws';
import si from "systeminformation";
const wss = new WebSocketServer({ port: 8080 });
wss.on('connection', function connection(ws) {
ws.on('message', function message(data) {
console.log('received: %s', data);
});
ws.send('Hey!, Welcome to the websocket server!');
setInterval(async () => {
const cpuTemp = JSON.stringify(await si.currentLoad());
ws.send(cpuTemp);
}, 1000);
});
つみっくり、さらっとばしっくり。
node server.js
屋 接続 ハプアールへ。は、CPU を 1 秒きにくくくぞく。
コア金成し、CPUINMINNETDぎぎぎぎぎぎぎぎぎぎぎら。この機会に。WebSocket「」、「チャットプー」、「サヨン」、「サヨン」、「サポーター」、「サモリ」など。
Github ソースコックス- https://github.com/icon-gaurav/node-websockets.git