1
0
This commit is contained in:
Your Name 2023-07-08 17:12:37 +08:00
parent 7342f14f05
commit 15b483ba80

View File

@ -4,6 +4,7 @@ std::vector<struct lws*> websockets;
DDNetCQ* DDNetCQ::instance=nullptr; DDNetCQ* DDNetCQ::instance=nullptr;
DDNetCQ* const ddncq=DDNetCQ::GetInstance(); DDNetCQ* const ddncq=DDNetCQ::GetInstance();
#define MAX_PLAYLOAD_LEN 10*1024 #define MAX_PLAYLOAD_LEN 10*1024
unsigned char msg[8196]="";
int WebSocketListener( struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len ) { int WebSocketListener( struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len ) {
switch (reason){ switch (reason){
case LWS_CALLBACK_ESTABLISHED: case LWS_CALLBACK_ESTABLISHED:
@ -12,11 +13,9 @@ int WebSocketListener( struct lws *wsi, enum lws_callback_reasons reason, void *
break; break;
case LWS_CALLBACK_RECEIVE: case LWS_CALLBACK_RECEIVE:
{ {
unsigned char* msg=new uint8_t[8192];
memset(msg,0,sizeof(msg)); memset(msg,0,sizeof(msg));
memcpy(msg,in,len); memcpy(msg,in,len);
ddncq->gamectx->SendChat(-1,CGameContext::CHAT_ALL,(const char*)msg); ddncq->gamectx->SendChat(-1,CGameContext::CHAT_ALL,(const char*)msg);
delete[] msg;
} }
break; break;
case LWS_CALLBACK_CLOSED: case LWS_CALLBACK_CLOSED: