Skip to content

Instantly share code, notes, and snippets.

@mayoz
Forked from p-baleine/app.js
Created June 14, 2013 20:10
Show Gist options
  • Save mayoz/5784892 to your computer and use it in GitHub Desktop.
Save mayoz/5784892 to your computer and use it in GitHub Desktop.
var express = require('express')
, io = require('socket.io');
var app = express()
, server = require('http').createServer(app)
, io = io.listen(server);
server.listen(3000);
io.sockets.on('connection', function(socket) {
socket.emit('news', { hello: 'world' });
socket.on('my other event', function(data) {
console.log(data);
});
});
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Hello World\n');
}).listen(8124);
console.log('Server running at http://127.0.0.1:8124/');
var socket = io.connect('https://dev-gw.beluga2010.jp', {
resource: 'tajima/socket-api/socket.io'
});
socket.on('news', function (data) {
console.log(data);
socket.emit('my other event', { my: 'data' });
});
{
"name": "beluga-socket-api",
"description": "Beluga socket.io server",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "3.x",
"socket.io": "0.9.10"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment