ssssss
Diff: CushionSock.h
- Revision:
- 0:01a2e92d2924
- Child:
- 1:e6addce35f93
diff -r 000000000000 -r 01a2e92d2924 CushionSock.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CushionSock.h Sat Dec 17 09:13:37 2016 +0000 @@ -0,0 +1,62 @@ +#ifndef CUSHION_SOCK_H +#define CUSHION_SOCK_H + +#include "mbed.h" +#include "Websocket.h" +#include "EthernetNetIf.h" +#include "picojson.h" +#include "MbedJSONValue.h" + + +class CushionSock +{ + public: + int MESS_STOP; + int MESS_START; + int MESS_SIT; + int MESS_FRUST; + int MESS_TEST; + + /* + Constructor + @param hostAndport format : "hostname:port" + */ + CushionSock(char * hostAndPort); + + /* + connect to server + @return true if the connection is established, false otherwise + */ + bool connect(); + + /* + send message to server + @return the number of bytes sent + @param type Message type(prease show and choose from line 14 to 17 in souece code) + @param msg message payload + */ + int mess_send(int type, char * msg); + + /* + Recieve message from server + @return if recieved succsessful, Message type(prease show and choose from line 14 to 17 in souece code), otherwise returns -1. + @param msg pointer to the message to be read. + */ + int mess_recv(char * msg); + + /* + To see if there is a SocketIO connection active + @return true if there is a connection active + */ + bool is_connected(); + + bool close(); + + private: + EthernetNetIf *eth; + Websocket *ws; + + std::map<int,string> type_name; + std::map<string,int> name_type; +}; +#endif \ No newline at end of file