Created
December 19, 2011 17:09
-
-
Save nash716/1498004 to your computer and use it in GitHub Desktop.
index_pickup.html
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
<script type="text/javascript"> | |
var socket; | |
$(document).ready(function() { | |
socket = new io.Socket(); | |
socket.connect(); | |
// 接続成功 | |
socket.on('connect', function() { | |
$('#select').show(); | |
$('#status').text('サーバーと接続成功!'); | |
}); | |
// 接続が切れた | |
socket.on('disconnect', function(message){ | |
alert('disconnected'); | |
}); | |
}); | |
function controller() { | |
$('#select').hide(); | |
$('#controller').show(); | |
$('#status').text('コマンドを選択…'); | |
} | |
function receiver() { | |
location.hash = 'receive'; | |
$('#select').hide(); | |
$('#receiver').show(); | |
$('#status').text('受信待ち…'); | |
socket.on('message', function(mes) { | |
location.hash = 'receive/' + mes; | |
location.hash = 'receive'; | |
}); | |
} | |
function send(type) { | |
socket.send(JSON.stringify({"type": type})); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment