c++ websocket sdrlib calaos

1.

https://github.com/ishmal/sdrlib/

https://github.com/allinurl/gwsocket

 

https://github.com/StanfordSNR/puffer

 

https://github.com/calaos/calaos_base

std::list<WebSocket *> connections;

static void onOpen(WsHandler *ws, char *msg)
{
//    SdrServer *svr = (SdrServer *) ws->context;
//    SdrLib *sdr = svr->sdr;
    WebSocket *conn = new WebSocket();
    conn->ws = ws;
    
    ws->context = conn;
    
    connections.push_back(conn);
    
}

static void onClose(WsHandler *ws, char *msg)
{
//    SdrServer *svr = (SdrServer *) ws->context;
//    SdrLib *sdr = svr->sdr;
    
    WebSocket *conn = (WebSocket *) ws->context;
    connections.remove(conn);
    delete conn;
    
    ws->context = NULL;
}

static void onMessage(WsHandler *ws, unsigned char *data, int len)
{
//    SdrServer *svr = (SdrServer *) ws->context;
//    SdrLib *sdr = svr->sdr;
//
//    int ret = parseAndExecute(sdr, (char *)data);
    printf("%s\n",(char *)data);
    
    WebSocket *conn = (WebSocket *) ws->context;
    string str((char *)data);
    conn->ProcessData(str);
}

 

posted @ 2020-12-13 21:29  lianhuaren  阅读(20)  评论(0编辑  收藏  举报