Simple websocket client based on the original with a few added features such as: - setBaud() - set the baud rate for the communication - Initialize() - mimics the constructor - chaged read() to readmsg() to avoid confusion with other functions
Dependents: IoT_Ex BatteryModelTester BatteryModelTester
Fork of WebSocketClient by
Revision 11:85bff70bab45, committed 2016-03-30
- Comitter:
- defrost
- Date:
- Wed Mar 30 10:40:05 2016 +0000
- Parent:
- 10:fc40c56e8a3c
- Child:
- 12:0979caf96fa6
- Commit message:
- - Added default constructor; - Added Initialize() method to mimic the constructor
Changed in this revision
Websocket.cpp | Show annotated file Show diff for this revision Revisions of this file |
Websocket.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Websocket.cpp Wed Mar 30 09:05:44 2016 +0000 +++ b/Websocket.cpp Wed Mar 30 10:40:05 2016 +0000 @@ -4,7 +4,7 @@ #define MAX_TRY_READ 10 //Debug is disabled by default -#if 1 +#if 0 #define DBG(x, ...) std::printf("[WebSocket : DBG]"x"\r\n", ##__VA_ARGS__); #define WARN(x, ...) std::printf("[WebSocket : WARN]"x"\r\n", ##__VA_ARGS__); #define ERR(x, ...) std::printf("[WebSocket : ERR]"x"\r\n", ##__VA_ARGS__); @@ -21,6 +21,15 @@ socket.set_blocking(false, 400); } +Websocket::Websocket() { + +} + +void Websocket::Initialize(char * url){ + fillFields(url); + socket.set_blocking(false, 400); +} + void Websocket::fillFields(char * url) { int ret = parseURL(url, scheme, sizeof(scheme), host, sizeof(host), &port, path, sizeof(path)); if(ret)
--- a/Websocket.h Wed Mar 30 09:05:44 2016 +0000 +++ b/Websocket.h Wed Mar 30 10:40:05 2016 +0000 @@ -74,6 +74,8 @@ * @param url The Websocket url in the form "ws://ip_domain[:port]/path" (by default: port = 80) */ Websocket(char * url); + Websocket(); + void Initialize(char * url); /** * Connect to the websocket url