Created
March 16, 2015 15:30
-
-
Save brlafreniere/05d6dfe97661bc37b543 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var app = require('./app'); | |
var http = require('http').Server(app); | |
var io = require('socket.io')(http); | |
var port = 3000; | |
io.on('connection', function(socket) { | |
console.log("A user connected."); | |
}); | |
io.on('message', function(data) { | |
// not seeing this in the server console | |
console.log('received message'); | |
}); | |
http.listen(port, function(err, res) { | |
console.log("Listening on port " + port); | |
}); |
This file contains hidden or 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
$(document).ready(function () { | |
var socket = io(); | |
$('#send').click(function (event) { | |
// I am seeing this in the client console | |
console.log("Send button clicked."); | |
var data = {}; | |
data.message = $('#message-box').val(); | |
data.nickname = 'billy'; | |
socket.emit('message', data); | |
$('#message-box').val(""); | |
}); | |
socket.on('receive-message', function(data) { | |
$('chat-window').append("<div>"+data.nickname+": "+data.message+"</div>"); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment