-
-
Save mayoz/5784892 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' }); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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