Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var util = require('util'),
- io = require('socket.io'),
- app = require('http').createServer(handler);
- var socket = io.listen(app);
- app.listen(8124);
- function handler(req, res) {
- res.writeHead(200,{ 'Content-Type': 'text/html' });
- res.end('<h1>Hello Socket Lover!</h1>');
- };
- socket.sockets.on("connection", function (client) {
- client.on("newPost", function (name,cont) {
- util.log("Received a new post by "+name+", with the content of \""+cont+"\".");
- this.broadcast.emit("Post", name, cont);
- util.log("Post sent!");
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement