-
Notifications
You must be signed in to change notification settings - Fork 34
/
server.js
39 lines (30 loc) · 968 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var socket = require( './public/node_modules/socket.io' );
var express = require('./public/node_modules/express');
var app = express();
var server = require('http').createServer(app);
var io = socket.listen( server );
var port = process.env.PORT || 3000;
server.listen(port, function () {
console.log('Server listening at port %d', port);
});
io.on('connection', function (socket) {
socket.on( 'new_count_message', function( data ) {
io.sockets.emit( 'new_count_message', {
new_count_message: data.new_count_message
});
});
socket.on( 'update_count_message', function( data ) {
io.sockets.emit( 'update_count_message', {
update_count_message: data.update_count_message
});
});
socket.on( 'new_message', function( data ) {
io.sockets.emit( 'new_message', {
name: data.name,
email: data.email,
subject: data.subject,
created_at: data.created_at,
id: data.id
});
});
});