WebSocket client library
Revision 10:4f02275c34ee, committed 2011-08-25
- Comitter:
- samux
- Date:
- Thu Aug 25 06:09:01 2011 +0000
- Parent:
- 9:9fa055ed54b4
- Child:
- 11:094c86973097
- Commit message:
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 Aug 24 15:22:52 2011 +0000 +++ b/Websocket.cpp Thu Aug 25 06:09:01 2011 +0000 @@ -9,6 +9,15 @@ fillFields(wifi_use, url); } + +Websocket::Websocket(char * url) { + wifi_use = false; + eth_use = true; + eth_connected = false; + response_server_eth = false; + fillFields(wifi_use, url); +} + void Websocket::fillFields(bool wifi, char * url) { char *res = NULL; char *res1 = NULL; @@ -77,17 +86,6 @@ } -Websocket::Websocket(char * url) { - wifi_use = false; - eth_use = true; - eth_writeable = false; - eth_readable = false; - eth_connected = false; - response_server_eth = false; - fillFields(wifi_use, url); -} - - bool Websocket::connect() {
--- a/Websocket.h Wed Aug 24 15:22:52 2011 +0000 +++ b/Websocket.h Thu Aug 25 06:09:01 2011 +0000 @@ -39,9 +39,9 @@ /** Websocket client Class. * - * Warning: you must use a wifi module (Wifly RN131-C) to use this class + * Warning: you must use a wifi module (Wifly RN131-C or RN131-g) to use this class or an ethernet connection * - * Example: + * Example with a Wifi module (Wifly RN131-C or RNR131-g): * @code * #include "mbed.h" * #include "Wifly.h" @@ -54,7 +54,7 @@ * int main() * { * wifly = new Wifly(p9, p10, p20, "network", "password", true); - * ws = new Websocket("ws://ip_domain/path", 80, wifly); + * ws = new Websocket("ws://ip_domain:443/path", wifly); * * if(wifly->Join()) * { @@ -75,6 +75,25 @@ * * } * @endcode + * + * + * Example with an Ethernet Jack: + * @code + * #include "mbed.h" + * #include "Websocket.h" + * + * Serial pc(USBTX, USBRX); + * Websocket * ws; + * + * int main() + * { + * ws = new Websocket("ws://ip_domain:443/path"); + * + * while(!ws->connect()) + * pc.printf("cannot connect webasocekt\r\n"); + * + * ws->Send("Hello World!"); + * } */ class Websocket { @@ -118,9 +137,9 @@ bool read(char * message); /** - * To see if there is a websocket connection active + * To see if there is an active websocket connection * - * @return true if there is a connection active + * @return true if there is an active websocket connection */ bool connected(); @@ -145,8 +164,6 @@ Wifly * wifi; bool eth_connected; - bool eth_readable; - bool eth_writeable; char eth_rx[512]; bool response_server_eth;