Created
March 27, 2014 04:04
-
-
Save KazChe/9799976 to your computer and use it in GitHub Desktop.
blog_socketio_client_js
This file contains 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
// This is important, the io.connect has to point where socket server | |
// is running - simple but took me while to connect the periods/dots/slashes...it's weekend, what am I doing? | |
var socket = io.connect('http://localhost:8111'); | |
// image related socket | |
socket.on('user image', function(m){ | |
// $('#imageReceivedMessage').text("> "+m); | |
$('#imageSentFromServer').attr('src', m); | |
}); | |
socket.on('connect', function(id){ | |
$('#status').text('Connected'); | |
}); | |
socket.on('setID', function(myID) { | |
console.log('receive id: ' + myID) | |
$('#IDReceivedMessage').text(myID) | |
}); | |
socket.on('message', function(m){ | |
$('#message').text("> "+m); | |
}); | |
socket.on('disconnect', function(){ | |
$('#status').text('Disconnected'); | |
}); | |
socket.on('customEvent', function(message) { | |
$('#customEvent').text(">> "+message['time']); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment