removed all the footers; formated all the files

This commit is contained in:
Oling Cat
2012-11-01 16:10:44 +08:00
parent 77b8677ae0
commit c059171e15
73 changed files with 4576 additions and 4782 deletions

69
8.2.md
View File

@@ -21,7 +21,7 @@ WebSocket的协议颇为简单在第一次handshake通过以后连接便
![](images/8.2.websocket2.png?raw=true)
在请求中的"Sec-WebSocket-Key"是随机的对于整天跟编码打交到的程序员一眼就可以看出来这个是一个经过base64编码后的数据。服务器端接收到这个请求之后需要把这个字符串连接上一个固定的字符串
258EAFA5-E914-47DA-95CA-C5AB0DC85B11
即:`f7cb4ezEAl6C3wRaU6JORA==`连接上那一串固定字符串,生成一个这样的字符串:
@@ -44,41 +44,41 @@ WebSocket分为客户端和服务端接下来我们将实现一个简单的
<html>
<head></head>
<body>
<script type="text/javascript">
var sock = null;
var wsuri = "ws://127.0.0.1:1234";
<script type="text/javascript">
var sock = null;
var wsuri = "ws://127.0.0.1:1234";
window.onload = function() {
window.onload = function() {
console.log("onload");
console.log("onload");
sock = new WebSocket(wsuri);
sock = new WebSocket(wsuri);
sock.onopen = function() {
console.log("connected to " + wsuri);
}
sock.onopen = function() {
console.log("connected to " + wsuri);
}
sock.onclose = function(e) {
console.log("connection closed (" + e.code + ")");
}
sock.onclose = function(e) {
console.log("connection closed (" + e.code + ")");
}
sock.onmessage = function(e) {
console.log("message received: " + e.data);
}
};
sock.onmessage = function(e) {
console.log("message received: " + e.data);
}
};
function send() {
var msg = document.getElementById('message').value;
sock.send(msg);
};
</script>
<h1>WebSocket Echo Test</h1>
<form>
<p>
Message: <input id="message" type="text" value="Hello, world!">
</p>
</form>
<button onclick="send();">Send Message</button>
function send() {
var msg = document.getElementById('message').value;
sock.send(msg);
};
</script>
<h1>WebSocket Echo Test</h1>
<form>
<p>
Message: <input id="message" type="text" value="Hello, world!">
</p>
</form>
<button onclick="send();">Send Message</button>
</body>
</html>
@@ -139,10 +139,7 @@ WebSocket分为客户端和服务端接下来我们将实现一个简单的
通过上面的例子我们看到客户端和服务器端实现WebSocket非常的方便Go的源码net分支中已经实现了这个的协议我们可以直接拿来用目前随着HTML5的发展我想未来WebSocket会是Web开发的一个重点我们需要储备这方面的知识。
## links
* [目录](<preface.md>)
* 上一节: [Socket编程](<8.1.md>)
* 下一节: [REST](<8.3.md>)
## LastModified
* $Id$
## links
* [目录](<preface.md>)
* 上一节: [Socket编程](<8.1.md>)
* 下一节: [REST](<8.3.md>)