• R/O
  • SSH
  • HTTPS

webserver: Commit


Commit MetaInfo

Revision69 (tree)
Time2011-05-28 23:05:34
Authorhoritaku

Log Message

WebSocket周り修正

Change Summary

Incremental Difference

--- branch/Basic 0.2x/docRoot2/index.html (revision 68)
+++ branch/Basic 0.2x/docRoot2/index.html (revision 69)
@@ -13,7 +13,7 @@
1313 <!--
1414 var ws = new WebSocket("ws://localhost/WebTest.ws");
1515 ws.onmessage = function(msg) {
16- alert(msg.data);
16+ document.getElementById('test').innerHTML += "<p>" + msg.data + "</p>";
1717 }
1818 ws.onopen = function(){
1919 ws.send('message');
--- branch/Basic 0.2x/config/web_server.ini (revision 68)
+++ branch/Basic 0.2x/config/web_server.ini (revision 69)
@@ -1,6 +1,6 @@
1-irDir=./docRoot3
1+irDir=./docRoot2
22 icDir=./config/reflectConfig.ini
33 userSecury=false
44 compress=gzip
55
6-port=8080
\ No newline at end of file
6+port=80
\ No newline at end of file
--- branch/Basic 0.2x/sokect_action/socket_action/WebTest.java (revision 68)
+++ branch/Basic 0.2x/sokect_action/socket_action/WebTest.java (revision 69)
@@ -14,7 +14,8 @@
1414 System.out.println("\r\nWebTest start");
1515 while(cont) {
1616 try {
17- Thread.sleep(10);
17+ Thread.sleep(2000);
18+ send(String.valueOf(System.currentTimeMillis()));
1819 } catch (InterruptedException e) {
1920 // TODO 自動生成された catch ブロック
2021 e.printStackTrace();
--- branch/Basic 0.2x/src/servercore/job/JobWorker.java (revision 68)
+++ branch/Basic 0.2x/src/servercore/job/JobWorker.java (revision 69)
@@ -246,7 +246,7 @@
246246 String editedDate = sdf.format(new Date(milliSecound));
247247 return editedDate;
248248 }
249- public void websocketHandShake(HttpRequest req, OutputStream ops, InputStream ips) {
249+ private void websocketHandShake(HttpRequest req, OutputStream ops, InputStream ips) {
250250 String host = req.getHeader().get("Host");
251251 StringBuffer sb = new StringBuffer();
252252 try {
@@ -255,7 +255,11 @@
255255 String key2 = req.getHeader().get("Sec-WebSocket-Key2");
256256 String origin = req.getHeader().get("Origin");
257257 String res_ws = "ws://" + host + path;
258- byte[] body_code = getChalengeKey(req.headerBytes);
258+ byte[] webSocketsByte = new byte[128];
259+ int readBytes = ips.read(webSocketsByte);
260+ byte[] body_code = new byte[readBytes];
261+ System.arraycopy(webSocketsByte, 0, body_code, 0,readBytes);
262+ System.out.println(body_code);
259263 long key1_num = chooseNum(key1);
260264 long key2_num = chooseNum(key2);
261265 int key1_s = chooseSpace(key1);
--- branch/Basic 0.2x/src/servercore/job/GeneratePage.java (revision 68)
+++ branch/Basic 0.2x/src/servercore/job/GeneratePage.java (revision 69)
@@ -53,7 +53,10 @@
5353 res.setStatusCore(404);
5454 } catch (Exception e) {
5555 res.setStatusCore(500);
56- e = (Exception)e.getCause();
56+ Exception ex = (Exception)e.getCause();
57+ if(ex != null) {
58+ e = ex;
59+ }
5760 String msg = e.getMessage() == null ? e.toString() : e.getMessage();
5861 res.setResponseStr(msg);
5962 e.printStackTrace();
@@ -79,7 +82,11 @@
7982 String key2 = req.getHeader().get("Sec-WebSocket-Key2");
8083 String origin = req.getHeader().get("Origin");
8184 String res_ws = "ws://" + host + path;
82- byte[] body_code = getChalengeKey(req.headerBytes);
85+ byte[] webSocketsByte = new byte[128];
86+ int readBytes = ips.read(webSocketsByte);
87+ byte[] body_code = new byte[readBytes];
88+ System.arraycopy(webSocketsByte, 0, body_code, 0,readBytes);
89+ System.out.println(body_code);
8390 long key1_num = chooseNum(key1);
8491 long key2_num = chooseNum(key2);
8592 int key1_s = chooseSpace(key1);
@@ -104,7 +111,6 @@
104111 ops.write(sb.toString().getBytes());
105112 ops.write(hash);
106113
107-
108114 Class<Action> cls = null;
109115
110116 cls = (Class<Action>)Class.forName(PackageName);
--- branch/Basic 0.2x/src/servercore/http/HttpServer.java (revision 68)
+++ branch/Basic 0.2x/src/servercore/http/HttpServer.java (revision 69)
@@ -87,7 +87,7 @@
8787 TcpServer server = new TcpServer();
8888 try {
8989 StartTest starttest = new StartTest();
90- starttest.start();
90+ //starttest.start();
9191
9292 TcpServer.setPortNum(recvPort);
9393 server.start();
Show on old repository browser