Created
October 13, 2011 05:04
-
-
Save glassesfactory/1283433 to your computer and use it in GitHub Desktop.
Socket.IO + Flash example. server side source codes.
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
[program:worm] | |
priority=3 | |
command= /usr/local/bin/node /var/www/dev/node_worm.js | |
user=root | |
autostart=true | |
autorestart=true | |
redirect_stderr=true | |
exitcodes=0 | |
stopsignal=INT | |
stdout_logfile=/var/log/test4js.log | |
stderr_logfile=/var/log/test4js.log |
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
/*//////////////////////////////////////////// | |
* | |
* node-test | |
* | |
* Autor: glasses factory | |
* Date: 11/10/04 | |
* | |
* Copyright 2011 glasses factory | |
* http://glasses-factory.net | |
* | |
/*//////////////////////////////////////////// | |
var app = require('http').createServer(handler); | |
var io = require('socket.io').listen(app); | |
io.configure('production', function(){ | |
io.set('trasnports', ['flashsocket','websocket','htmlfile','xhr-poling','jsonp-poling']); | |
}); | |
var lounge = {}; | |
var loungeNum = 0; | |
io.sockets.on( 'connection', function(socket) { | |
console.log('ほむほむ'); | |
socket.on('user add', function(data) { | |
lounge[socket.id] = {userID:socket.id, color:data.color, ww:20 }; | |
loungeNum++; | |
socket.emit('$joined', {userID:socket.id}); | |
socket.emit('$userList', {list:lounge, num:loungeNum}); | |
socket.broadcast.emit('$$new user join', { userID:socket.id, color:data.color, num:loungeNum }); | |
}); | |
socket.on('lounge info',function(data) { | |
socket.emit('$lounge info', {list:lounge, num:loungeNum}); | |
}); | |
socket.on( 'mpt', function(data){ | |
socket.broadcast.emit('$$move-other', { userID:socket.id, x:data.xx, y:data.yy }) | |
}); | |
socket.on( 'colorChange', function(data){ | |
lounge[socket.id].color = data.color; | |
lounge[socket.id].ww = data.ww; | |
lounge[socket.id].th = data.th; | |
socket.broadcast.emit( '$$user color change', { userID:socket.id, color:data.color, ww:data.ww, th:data.th }); | |
}); | |
socket.on( 'disconnect', function(data){ | |
delete lounge[socket.id]; | |
loungeNum--; | |
socket.broadcast.emit('$$user_disconnected', { userID:socket.id, num:loungeNum }) | |
}); | |
}); | |
app.listen(3001); | |
function handler( req, res ) { | |
res.writeHead(200); | |
res.end('(´・ω`・)エッ?'); | |
} | |
console.log('Server running at : 3001'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment