Skip to content

Instantly share code, notes, and snippets.

@nash716
Created December 19, 2011 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nash716/1498004 to your computer and use it in GitHub Desktop.
Save nash716/1498004 to your computer and use it in GitHub Desktop.
index_pickup.html
<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