Created
September 19, 2012 03:29
-
-
Save gkop/3747504 to your computer and use it in GitHub Desktop.
Chat client
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
$(document).ready -> | |
ws = new WebSocket("ws://localhost:9000/chat") | |
ws.onopen = -> | |
console.log "connected..." | |
ws.onmessage = (event) -> | |
console.log event | |
$("<li>#{event.data}</li>").prependTo("#msg") | |
ws.onclose = -> | |
console.log "socket closed" | |
$("#submit").click -> | |
nick = $("#nick").val() | |
msg = $("#message").val() | |
ws.send "#{nick}: #{msg}" | |
false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment