What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-10 04:13:14
nodejs api to logged in users count on an application
var io = require('socket.io').listen(8080); var count = 0 io.sockets.on('connection', function(socket) { count++; io.sockets.emit('message', { count: count }); socket.on('disconnect', function(){ count--; io.sockets.emit('mes... Add solution -
Javascript 2021-11-09 17:24:12
Express.js - app.listen vs server.listen
//The second form (creating an HTTP server yourself, instead of having Express create one for you) is useful if you want to reuse the HTTP server, for example to run socket.io within the same HTTP server instance: var express = require('express'); var ap... Add solution -
Javascript 2021-10-22 06:12:09
socket io emit to socket id
socket.emit('message', "this is a test"); //sending to sender-client only socket.broadcast.emit('message', "this is a test"); //sending to all clients except sender socket.broadcast.to('game').emit('message', 'nice game'); //sending to... Add solution -
Javascript 2021-10-20 06:34:05
call node js function from javascript
var io = require('socket.io').listen(80); // initiate socket.io server io.sockets.on('connection', function (socket) { socket.emit('news', { hello: 'world' }); // Send data to client // wait for the event raised by the client socket.on('my other e... Add solution -
Javascript 2021-09-23 00:27:02
js socket.emit
var socket = io.connect('http://localhost'); socket.emit('my other event', { my: 'data' }); //server side io.sockets.on('connection', function (socket) { socket.on('my other event', function (data) { console.log(data); }); }); //sending data from ... Add solution -
Javascript 2021-09-21 22:31:07
socket.io client send data node js server
var socket = io.connect('http://localhost'); socket.emit('my other event', { my: 'data' }); //server side io.sockets.on('connection', function (socket) { socket.on('my other event', function (data) { console.log(data); }); }); //sending data from ... Add solution -
Other 2021-09-16 06:38:03
socket io emit to specific client
socket.emit('message', "this is a test"); //sending to sender-client only socket.broadcast.emit('message', "this is a test"); //sending to all clients except sender socket.broadcast.to('game').emit('message', 'nice game'); //sending to... Add solution