Advertisement
Xavion

Untitled

May 5th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. var util = require('util'),
  2. io = require('socket.io'),
  3. app = require('http').createServer(handler);
  4. var socket = io.listen(app);
  5. app.listen(8124);
  6. function handler(req, res) {
  7. res.writeHead(200,{ 'Content-Type': 'text/html' });
  8. res.end('<h1>Hello Socket Lover!</h1>');
  9. };
  10. socket.sockets.on("connection", function (client) {
  11. client.on("newPost", function (name,cont) {
  12. util.log("Received a new post by "+name+", with the content of \""+cont+"\".");
  13. this.broadcast.emit("Post", name, cont);
  14. util.log("Post sent!");
  15. });
  16. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement