-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from hasegaw/feature/statink_submit_event
Feature/statink submit event
- Loading branch information
Showing
5 changed files
with
135 additions
and
8 deletions.
There are no files selected for viewing
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 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 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 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!-- very simple WS sample --> | ||
|
||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<title>WebSocket Sample</title> | ||
<script src="https://code.jquery.com/jquery-latest.min.js"></script> | ||
<script> | ||
$(function(){ | ||
// WebSocket作成 | ||
var ws = new WebSocket("ws://localhost:9090/ws"); | ||
|
||
// WebSocket open時のイベントハンドラ登録 | ||
ws.onopen = function(){ | ||
$("#log").prepend("<onopen> " + "<br/>"); | ||
} | ||
|
||
// WebSocket message受信時のイベントハンドラ登録 | ||
ws.onmessage = function(message){ | ||
$("#log").prepend(message.data + "<br/>"); | ||
} | ||
|
||
// WebSocket error時のイベントハンドラ登録 | ||
ws.onerror = function(){ | ||
$("#log").prepend("<onerror> " + "<br/>"); | ||
} | ||
|
||
// WebSocket close時のイベントハンドラ登録 | ||
ws.onclose = function(){ | ||
$("#log").prepend("<onclose> " + "<br/>"); | ||
} | ||
|
||
// Windowが閉じられた(例:ブラウザを閉じた)時のイベントを設定 | ||
$(window).unload(function() { | ||
ws.onclose(); // WebSocket close | ||
}) | ||
|
||
// キー入力時のイベントを設定 | ||
// $("#message").keyup(function(e){ | ||
// ws.send($("#message").val()); // WebSocketを使いサーバにメッセージを送信 | ||
// }); | ||
|
||
}) | ||
</script> | ||
</head> | ||
<body><input type="text" id="message" /><div id="log" /></body> | ||
</html> |