This commit is contained in:
azw 2023-08-18 15:40:46 +00:00
parent 91b5f74b3a
commit 0d5c381b38
3 changed files with 6 additions and 30 deletions

View File

@ -96,12 +96,10 @@ namespace a8
{ {
actived_ = true; actived_ = true;
connected_ = false; connected_ = false;
a8::XPrintf("remote_ip:%s remote_port:%d\n", {endpoint_->address().to_string(), endpoint_->port()});
socket_->async_connect socket_->async_connect
(*endpoint_, (*endpoint_,
[this] (const asio::error_code& ec) [this] (const asio::error_code& ec)
{ {
a8::XPrintf("async econnect %d\n", {ec.value()});
HandleConnect(ec); HandleConnect(ec);
}); });
} }

View File

@ -7,4 +7,9 @@ namespace a8
{ {
}; };
class NormalPromise : public Awaiter
{
std::function<(std::shared_ptr<a8::Awaiter>)> cb;
};
} }

View File

@ -175,38 +175,11 @@ namespace a8
if (!pend) { if (!pend) {
return; 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; handshook_ = true;
offset += pend - buf - offset + strlen("\r\n\r\n"); offset += pend - buf - offset + strlen("\r\n\r\n");
if (on_connect) { if (on_connect) {
on_connect(this); on_connect(this);
} }
#endif
} }
void WebSocketClient::ProcessUserPacket() void WebSocketClient::ProcessUserPacket()
@ -318,7 +291,7 @@ namespace a8
void WebSocketClient::DecodeUserPacket(char* buf, int& offset, unsigned int buflen) void WebSocketClient::DecodeUserPacket(char* buf, int& offset, unsigned int buflen)
{ {
int i = 0;
} }
} }