How to use socket - 10 common examples

To help you get started, we’ve selected a few socket 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 mockstarjs / mockstar / packages / mockstar-client / src / model / SocketClient.js View on Github external
constructor(url) {
        this.url = url || 'http://local.mockstarjs.org';

        this.socket = io(this.url);

        // 序列号,用于识别不同的事件
        this._seq = 0;

        this.init();
    }
github vincentwoo / setgame / server.js View on Github external
io.configure('production', function() {
  io.enable('browser client minification');  // send minified client
  io.enable('browser client etag');          // apply etag caching logic based on version number
  io.enable('browser client gzip');          // gzip the file
  io.set('log level', 1);                    // reduce logging
  io.set('transports', [                     // enable all transports (optional if you want flashsocket)
      'websocket'
    , 'flashsocket'
    , 'htmlfile'
    , 'xhr-polling'
    , 'jsonp-polling'
  ]);
});
github Cryptkeeper / Minetrack / lib / server.js View on Github external
exports.start = function() {
	setupRoutes();

	// Create our tiny little HTTP server.
	var server = http.createServer(handleRequest);

	server.listen(config.site.port, config.site.ip);

	// I don't like this. But it works, I think.
	exports.io = io.listen(server);

	// Since everything is loaded, let's celebrate!
	logger.log('info', 'Started on %s:%d', config.site.ip, config.site.port);
};
github volumio / Volumio2 / utils / pluginapi / uninstallPlugin.js View on Github external
/**
 * Created by massi on 30/08/15.
 */
var io=require('socket.io-client');

var socket= io.connect('http://localhost:3000');

console.log("GET BrowseLibrary\n\n");
socket.emit('unInstallPlugin', { category:'music_services',name:''});

socket.on('installPluginStatus',function(data)
{
    console.log(data);
//console.log(JSON.parse(data));
});
github volumio / Volumio2 / app / plugins / system_controller / volumio_command_line_client / commands / status.js View on Github external
#!/bin/node
var io=require('socket.io-client');

var socket= io.connect('http://localhost:3000');

socket.emit('getState', '');

socket.on('pushState',function(data)
{
    console.log(data);
    process.exit()
});
github volumio / Volumio2 / utils / pluginapi / enablePlugin.js View on Github external
/**
 * Created by massi on 30/08/15.
 */
var io=require('socket.io-client');

var socket= io.connect('http://localhost:3000');


socket.emit('setBackgrounds',{name:'Morning',path:'morning.jpg'});

socket.on('pushBackgrounds',function(data)
{
    console.log(data);
//console.log(JSON.parse(data));
});
github volumio / Volumio2 / utils / pluginapi / preuninstallPlugin.js View on Github external
/**
 * Created by massi on 30/08/15.
 */
var io=require('socket.io-client');

var socket= io.connect('http://localhost:3000');

console.log("GET BrowseLibrary\n\n");
socket.emit('preUninstallPlugin', { category:'music_service',name:'spop'});

socket.on('openModal',function(data)
{
    console.log(data);
//console.log(JSON.parse(data));
});
github volumio / Volumio2 / app / plugins / system_controller / volumio_command_line_client / commands / setvolume.js View on Github external
#!/bin/node
var io=require('socket.io-client');
var socket= io.connect('http://localhost:3000');
var volume = Number(process.argv.slice(2));

socket.emit('volume', volume);

socket.on('pushState',function(data)
{
    console.log('Volume is now: '+data.volume);
    process.exit()
});
github jawerty / brocast / signaling_server / server.js View on Github external
var http = require('http');

server = http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, '127.0.0.1');

var io = require('socket.io').listen(server);

io.sockets.on('connection', function(socket) {
 socket.on('message', function(message) {
   socket.broadcast.emit('message', message);
 });
});

console.log('Server running at http://127.0.0.1:1337/');
github wayou / HiChat / app.js View on Github external
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io').listen(server);

server.listen(80); //for local test
//server.listen(process.env.PORT || 3000);//for publish to heroku

app.use("/", express.static(__dirname + '/public'));

io.sockets.on('connection', function (socket) {
  socket.on('msg', function (data) {
    io.sockets.emit('new', data);
  });
});

socket

CLI tool for Socket.dev

MIT
Latest version published 6 days ago

Package Health Score

78 / 100
Full package analysis