Permalink
Browse files

Receive responses

  • Loading branch information...
kaborso committed Sep 10, 2011
1 parent 97d33dd commit 7bfa204483ceb42753afc92bba5f4f3741969cce
Showing with 15 additions and 14 deletions.
  1. +8 −6 app.js
  2. +7 −8 public/javascripts/app.js
View
14 app.js
@@ -1,6 +1,7 @@
var sys = require('sys');
var express = require('express');
var io = require('socket.io');
+var util = require('util');
var app = express.createServer();
@@ -25,10 +26,11 @@ app.get('/', function(req, res) {
app.listen(8080);
-var socket = io.listen(app);
+var io = io.listen(app);
+
+io.sockets.on('connection', function (client) {
+ client.on('message', function (message) {
+ client.send('message');
+ });
+});
-socket.on('connection', function (client) {
- client.on('message', function (message) {
- socket.broadcast(message);
- });
-});
View
@@ -5,17 +5,16 @@
//var socket = new io.Socket(null, {rememberTransport: false, port: 8080});
socket.on('connect', function() {
- socket.emit('initial', { event: 'initial', message: 'boo!' });
+ socket.emit('message', { event: 'initial', message: 'boo!' });
+ socket.on('message', function (newMessage) {
+ alert('');
+ $('body').append(newMessage)
+ });
});
-
- socket.on('message', function (newMessage) {
- $('body').append(newMessage)
- });
-
+
$(document).ready(function(){
$(".sendMsg").click(function(){
- socket.send('testing');
+ socket.send('message', { data: 'stuff'} );
});
})
-
})();

0 comments on commit 7bfa204

Please sign in to comment.