WebSocket client library

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Tue Aug 30 09:25:28 2011 +0000
Parent:
12:1f6b9451a608
Child:
14:c5ac3e26998f
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	Fri Aug 26 09:17:30 2011 +0000
+++ b/Websocket.cpp	Tue Aug 30 09:25:28 2011 +0000
@@ -9,6 +9,19 @@
     fillFields(wifi_use, url);
 }
 
+
+Websocket::Websocket(char * url) {
+    wifi_use = false;
+    server_ip = NULL;
+    eth_use = true;
+    eth_writeable = false;
+    eth_readable = false;
+    eth_connected = false;
+    response_server_eth = false;
+    fillFields(wifi_use, url);
+}
+
+
 void Websocket::fillFields(bool wifi, char * url) {
     char *res = NULL;
     char *res1 = NULL;
@@ -72,20 +85,6 @@
 }
 
 
-Websocket::Websocket(char * url) {
-    wifi_use = false;
-    server_ip = NULL;
-    eth_use = true;
-    eth_writeable = false;
-    eth_readable = false;
-    eth_connected = false;
-    response_server_eth = false;
-    fillFields(wifi_use, url);
-}
-
-
-
-
 bool Websocket::connect() {
     char cmd[50];
     if ( wifi_use ) {
--- a/Websocket.h	Fri Aug 26 09:17:30 2011 +0000
+++ b/Websocket.h	Tue Aug 30 09:25:28 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 an ethernet network to use this class
  *
- * Example:
+ * Example (wifi network):
  * @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/path", wifly);
  *   
  *   if(wifly->Join())
  *   {
@@ -75,6 +75,34 @@
  *       
  * }
  * @endcode
+ *
+ *
+ *
+ * Example (ethernet network):
+ * @code
+ * #include "mbed.h"
+ * #include "Websocket.h"
+ * 
+ * Serial pc(USBTX, USBRX);
+ * Websocket * ws;
+ *
+ * int main()
+ * {
+ *   ws = new Websocket("ws://ip_domain/path");
+ *   
+ *   if(ws->connect())
+ *   {
+ *      pc.printf("ws connected\r\n");
+ *      while(1)
+ *      {
+ *         wait(0.1);
+ *         ws->Send("test");
+ *      }
+ *   }
+ *   else
+ *      pc.printf("ws not connected\r\n");
+ * }
+ * @endcode
  */
 class Websocket
 {