From 0d5c381b38618310d7b438a03c8942b14c0e0725 Mon Sep 17 00:00:00 2001 From: azw Date: Fri, 18 Aug 2023 15:40:46 +0000 Subject: [PATCH] 1 --- a8/asiotcpclient.cc | 2 -- a8/promise.h | 5 +++++ a8/websocketclient.cc | 29 +---------------------------- 3 files changed, 6 insertions(+), 30 deletions(-) diff --git a/a8/asiotcpclient.cc b/a8/asiotcpclient.cc index 848c39d..8610fbd 100644 --- a/a8/asiotcpclient.cc +++ b/a8/asiotcpclient.cc @@ -96,12 +96,10 @@ namespace a8 { actived_ = true; connected_ = false; - a8::XPrintf("remote_ip:%s remote_port:%d\n", {endpoint_->address().to_string(), endpoint_->port()}); socket_->async_connect (*endpoint_, [this] (const asio::error_code& ec) { - a8::XPrintf("async econnect %d\n", {ec.value()}); HandleConnect(ec); }); } diff --git a/a8/promise.h b/a8/promise.h index b602e28..3cc4d3e 100644 --- a/a8/promise.h +++ b/a8/promise.h @@ -7,4 +7,9 @@ namespace a8 { }; + class NormalPromise : public Awaiter + { + std::function<(std::shared_ptr)> cb; + }; + } diff --git a/a8/websocketclient.cc b/a8/websocketclient.cc index 98dc0b0..0dae9cb 100644 --- a/a8/websocketclient.cc +++ b/a8/websocketclient.cc @@ -175,38 +175,11 @@ namespace a8 if (!pend) { return; } - #if 0 - std::string server_key; - { - char* p1 = strstr(buf + offset, WEB_SOCKET_KEY); - if (!p1) { - p1 = strstr(buf + offset, WEB_SOCKET_KEY2); - } - if (p1) { - p1 += strlen(WEB_SOCKET_KEY); - char* p2 = strstr(p1 , "\r\n"); - if (p2) { - server_key.append(p1, p2-p1); - } - } - } - server_key += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; - std::string sha1_data = a8::openssl::Sha1Encode(server_key); - std::string hash_data; - a8::openssl::Base64Encode(sha1_data, hash_data); - - std::string response = "HTTP/1.1 101 Web Socket Protocol Handshake\r\n" - "Upgrade: websocket\r\n" - "Connection: Upgrade\r\n" - "Sec-WebSocket-Accept: " + hash_data + "\r\n" + - "\r\n"; - SendBuff(response.data(), response.size()); handshook_ = true; offset += pend - buf - offset + strlen("\r\n\r\n"); if (on_connect) { on_connect(this); } - #endif } void WebSocketClient::ProcessUserPacket() @@ -318,7 +291,7 @@ namespace a8 void WebSocketClient::DecodeUserPacket(char* buf, int& offset, unsigned int buflen) { - + int i = 0; } }