From c968da6825ca2e8ea9ce908caf1cac5feb8caa4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?shuxin=20=E3=80=80=E3=80=80zheng?= Date: Thu, 10 Feb 2022 09:50:00 +0800 Subject: [PATCH] fixed some bugs in websocket demo --- app/wizard_demo/fiber_chat/http_servlet.cpp | 2 +- app/wizard_demo/fiber_chat/http_servlet.h | 2 +- app/wizard_demo/fiber_chat/main.cpp | 2 +- app/wizard_demo/fiber_chat/user.html | 93 --------------------- app/wizard_demo/fiber_chat/www/user.html | 9 +- 5 files changed, 8 insertions(+), 100 deletions(-) delete mode 100644 app/wizard_demo/fiber_chat/user.html diff --git a/app/wizard_demo/fiber_chat/http_servlet.cpp b/app/wizard_demo/fiber_chat/http_servlet.cpp index ee685383a..92e8a95a7 100644 --- a/app/wizard_demo/fiber_chat/http_servlet.cpp +++ b/app/wizard_demo/fiber_chat/http_servlet.cpp @@ -95,7 +95,7 @@ bool http_servlet::doPost(acl::HttpServletRequest& req, return ret; } -bool http_servlet::doWebsocket(acl::HttpServletRequest& req, +bool http_servlet::doWebSocket(acl::HttpServletRequest& req, acl::HttpServletResponse&) { acl::socket_stream& ss = req.getSocketStream(); diff --git a/app/wizard_demo/fiber_chat/http_servlet.h b/app/wizard_demo/fiber_chat/http_servlet.h index 25b30f37c..6c7467d23 100644 --- a/app/wizard_demo/fiber_chat/http_servlet.h +++ b/app/wizard_demo/fiber_chat/http_servlet.h @@ -49,7 +49,7 @@ protected: bool doPost(acl::HttpServletRequest&, acl::HttpServletResponse&); // @override - bool doWebsocket(acl::HttpServletRequest&, acl::HttpServletResponse&); + bool doWebSocket(acl::HttpServletRequest&, acl::HttpServletResponse&); private: bool doPing(acl::websocket&, acl::websocket&); diff --git a/app/wizard_demo/fiber_chat/main.cpp b/app/wizard_demo/fiber_chat/main.cpp index 5db222d59..9b083b640 100644 --- a/app/wizard_demo/fiber_chat/main.cpp +++ b/app/wizard_demo/fiber_chat/main.cpp @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) addr = argv[3]; printf("listen: %s\r\n", addr); - ms.run_alone(addr, argc >= 3 ? argv[2] : NULL, 0); + ms.run_alone(addr, argc >= 3 ? argv[2] : NULL); } else ms.run_daemon(argc, argv); diff --git a/app/wizard_demo/fiber_chat/user.html b/app/wizard_demo/fiber_chat/user.html deleted file mode 100644 index 303512062..000000000 --- a/app/wizard_demo/fiber_chat/user.html +++ /dev/null @@ -1,93 +0,0 @@ - - -WebSocket Chat - - - -
-WebSocket -

Server url: - - -

-

- me: - -

-

- to:    -    - msg: - - -

- recv: -
-
-
-
- -
- - diff --git a/app/wizard_demo/fiber_chat/www/user.html b/app/wizard_demo/fiber_chat/www/user.html index cee14e978..102993a5f 100644 --- a/app/wizard_demo/fiber_chat/www/user.html +++ b/app/wizard_demo/fiber_chat/www/user.html @@ -23,11 +23,11 @@ } function onOpen(evt, user) { - setStatus("connected ..."); + setStatus("connected!"); } function onClose(evt) { - setStatus("disconnected ..."); + setStatus("disconnected!"); logined = false; user_list = new Array(); ws = null; @@ -158,6 +158,7 @@ message = "chat|" + msg + "|" + to_user; ws.send(message); document.getElementById(msgid).value = ""; + document.all.msg.focus(); } function doClear(output) { @@ -176,7 +177,7 @@
WebSocket Chat

Server url: - +

@@ -197,7 +198,7 @@


-
源码
+
源码