WebSocket client library

Revision:
6:01a1eb7c0145
Parent:
5:0f3422b6ca44
Child:
9:9fa055ed54b4
--- a/Websocket.h	Mon Aug 15 13:46:01 2011 +0000
+++ b/Websocket.h	Wed Aug 24 10:49:36 2011 +0000
@@ -33,6 +33,10 @@
 
 #include "mbed.h"
 #include "Wifly.h"
+#include "EthernetNetIf.h"
+#include "TCPSocket.h"
+#include "dnsresolve.h"
+
 /** Websocket client Class. 
  *
  * Warning: you must use a wifi module (Wifly RN131-C) to use this class
@@ -76,13 +80,20 @@
 {
     public:
         /**
-        * Constructor
+        * Constructor for a wifi module
         *
-        * @param url The Websocket url in the form "ws://ip_domain/path"
-        * @param port port
+        * @param url The Websocket url in the form "ws://ip_domain[:port]/path"  (by default: port = 80)
         * @param wifi pointer to a wifi module (the communication will be establish by this module)
         */
-        Websocket(char * url, int port, Wifly * wifi);
+        Websocket(char * url, Wifly * wifi);
+        
+        /**
+        * Constructor for an ethernet communication
+        *
+        * @param url The Websocket url in the form "ws://ip_domain[:port]/path" (by default: port = 80)
+        * @param port port
+        */
+        Websocket(char * url);
         
         /**
         * Connect to the websocket
@@ -120,12 +131,30 @@
         * @return true if the connection has been closed, false otherwise
         */
         bool close();
+        
+        
     
     private:
+        
+        void fillFields(bool wifi, char * url);
+        void onTCPSocketEvent(TCPSocketEvent e);
+        
         char * ip_domain;
         char * path;
-        int port;
+        char * port;
+        
         Wifly * wifi;
+        
+        bool eth_connected;
+        bool eth_readable;
+        bool eth_writeable;
+        
+        bool wifi_use;
+        bool eth_use;
+        
+        EthernetNetIf eth;
+        TCPSocket sock;
+        IpAddr server_ip;
 
 };