Websocket example

Dependencies:   C027 UbloxUSBModem WebSocketClient mbed

Fork of VodafoneUSBModemWebsocketTest by Donatien Garnier

Revision:
4:0f0cd888156b
Parent:
2:cc30dc616fa2
Child:
7:745fa95221ba
--- a/main.cpp	Fri Aug 17 16:19:10 2012 +0000
+++ b/main.cpp	Wed Aug 29 14:01:05 2012 +0000
@@ -15,18 +15,27 @@
       return;
     }
     
-    ws.connect();
- 
-    for(int i = 0; i < 500; i++)
+    bool c = ws.connect();
+    printf("Connect result: %s\n", c?"OK":"Failed");
+    
+    for(int i = 0; i < 10000; i++)
     {
         if(!(i%100))
-            ws.send("WebSocket Hello World over the Vodafone Network!");
- 
+        {
+          int ret = ws.send("WebSocket Hello World over the Vodafone Network!");
+          if(ret<0)
+          {
+            printf("Timeout\n");
+            ws.close();
+            c = ws.connect();
+            printf("Connect result: %s\n", c?"OK":"Failed");
+          }
+        }
+        
         if (ws.read(recv)) {
             printf("rcv: %s\r\n", recv);
         }
- 
-        Thread::wait(10);
+
     }
     
     modem.disconnect();