mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 13:08:20 +00:00
Copy docs into Zeek repo directly
This is based on commit 99e6942efec5feff50523f6b2a1f5868f19ab638 from the zeek-docs repo.
This commit is contained in:
parent
979a98c73c
commit
adce4e604a
1075 changed files with 169492 additions and 1 deletions
23
doc/devel/websocket-api/server.js
Normal file
23
doc/devel/websocket-api/server.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
// server.js
|
||||
import WebSocket, { WebSocketServer } from 'ws';
|
||||
|
||||
const wss = new WebSocketServer({ port: 8080 });
|
||||
|
||||
wss.on('connection', (ws, req) => {
|
||||
ws.on('error', console.error);
|
||||
ws.on('close', () => { console.log('%s: gone', ws.zeek.app); });
|
||||
|
||||
ws.on('message', function message(data) {
|
||||
console.log('%s: received: %s', ws.zeek.app, data);
|
||||
});
|
||||
|
||||
let topics = ['zeek.bridge.test'];
|
||||
let app = req.headers['x-application-name'] || '<unknown application>'
|
||||
ws.zeek = {
|
||||
app: app,
|
||||
topics: topics,
|
||||
};
|
||||
|
||||
console.log(`${app}: connected, sending topics array ${JSON.stringify(topics)}`);
|
||||
ws.send(JSON.stringify(topics));
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue