Init project

This commit is contained in:
dijunkun
2023-07-13 14:17:34 +08:00
commit ef6a04dc97
120 changed files with 26696 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
#include "ws_client.h"
#include <cstdlib>
#include <iostream>
#include <string>
#include <sstream>
class WsReceiver:public WsCore
{
public:
WsReceiver(){}
~WsReceiver(){}
void OnReceiveMessage(const std::string &msg)
{
LOG_INFO("Receive msg: {}", msg);
}
};
int main()
{
bool done = false;
std::string input;
WsReceiver ws_client;
LOG_INFO("connect ws://localhost:9002");
ws_client.Connect("ws://localhost:9002");
std::string status1 = ws_client.GetStatus();
while("Open" != status1)
{
status1 = ws_client.GetStatus();
}
LOG_INFO("Connect successfully!");
LOG_INFO("Send message [Hello]");
ws_client.Send("Hello");
LOG_INFO("Send ping");
ws_client.Ping();
LOG_INFO("Close conneciton");
int close_code = websocketpp::close::status::normal;
std::string reason = "User Close";
ws_client.Close(close_code, reason);
getchar();
return 0;
}