#include #include #include "websocket_test.h" class TestSession : public a8::WebSocketSession { public: virtual void DecodeUserPacket(char* buf, int& offset, unsigned int buflen) override { buf[buflen] = '\0'; printf("DecodeUserPacket:%s\n", buf + offset); SendBuff(buf + offset, buflen - offset); offset += buflen - offset; } }; static void CreateClientSocket(a8::TcpSession** p) { *p = new TestSession(); } static void SocketError(a8::TcpListener*, a8::TCPLISTENER_E, int) { assert(false); } void WebSocket_Test::Init() { tcp_listener_.on_create_client_socket = CreateClientSocket; tcp_listener_.on_error = SocketError; tcp_listener_.bind_address = "0.0.0.0"; tcp_listener_.bind_port = 80; tcp_listener_.Open(); } void WebSocket_Test::UnInit() { }