Hayato Hiratori / Mbed 2 deprecated WebSocketServerTest

Dependencies:   SNICInterface_mod WebSocketServer mbed-rtos mbed PowerControl C12832

WebSocketServer.h

Committer:
flatbird
Date:
2015-03-13
Revision:
1:84af7a219830
Parent:
0:f7596ed7ab5c
Child:
5:ce3f1dd90068

File content as of revision 1:84af7a219830:

#ifndef _WEB_SOCKET_SERVER_H_
#define _WEB_SOCKET_SERVER_H_

#include "TCPSocketServer.h"

class WebSocketHandler
{
public:
    virtual void onOpen() = 0;
    virtual void onClose() = 0;
    virtual void onMessage() = 0;
    virtual void onError() = 0;
};

class WebSocketServer
{
public:
    WebSocketServer();
    virtual ~WebSocketServer();

    bool init(int port);
    void run();
    bool setHandler(const char* path, WebSocketHandler* handler);

private:
    bool handleHTTP(char* buf, int size);
    bool handleWebSocket(char* buf, int size);
    TCPSocketServer mTCPSocketServer;
};

#endif