How to use the express-ws.app function in express-ws

To help you get started, we’ve selected a few express-ws examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github grasslandnetwork / node_lite / gui / src / server / index.js View on Github external
#!/usr/bin/env node
'use strict';

const net = require('net');
const express = require('express')

// const app = express()
const port = 8080

var expressWs = require('express-ws')
var expressWs = expressWs(express());
var app = expressWs.app;


var calibration;



app.use(express.static('dist'))

// Use this server to send calibration values received from map/browser down to node and ...
// ... send frame dimensions (frame_dim) received from node up to map/browser
app.ws('/send_calibration', (ws, req) => {
	// console.error('websocket connection from browser');
	// for (var t = 0; t < 3; t++)
	//   setTimeout(() => ws.send('Map, the server received your message', ()=>{}), 1000*t);

	ws.on('message', function incoming(message) {

express-ws

WebSocket endpoints for Express applications

BSD-2-Clause
Latest version published 3 years ago

Package Health Score

56 / 100
Full package analysis

Popular express-ws functions