Host library for controlling a WiConnect enabled Wi-Fi module.

Dependents:   wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more

Revision:
40:4b4306f3d829
Parent:
29:b6af04b77a56
diff -r a963f69cb2de -r 4b4306f3d829 TcpServer.cpp
--- a/TcpServer.cpp	Mon Feb 23 20:30:18 2015 -0800
+++ b/TcpServer.cpp	Mon Feb 23 22:21:50 2015 -0800
@@ -136,7 +136,7 @@
         uint32_t ipAddress;
         WiconnectResult result;
 
-        if(WICONNECT_SUCCEEDED(result, pollForServerClient(&handle, &local, &remote, &ipAddress)))
+        if(WICONNECT_SUCCEEDED(result, pollForClient(SOCKET_TYPE_TCP, &handle, &local, &remote, &ipAddress)))
         {
             char ipBuffer[17];
             if(WICONNECT_FAILED(result, socket.init(handle, SOCKET_TYPE_TCP, Wiconnect::ipToStr(ipAddress, ipBuffer), remote, local)))
@@ -171,7 +171,7 @@
 }
 
 /*************************************************************************************************/
-WiconnectResult SocketInterface::pollForServerClient(uint8_t *handlePtr, uint16_t *localPort, uint16_t *remotePort, uint32_t *ipAddress)
+WiconnectResult SocketInterface::pollForClient(SocketType type, uint8_t *handlePtr, uint16_t *localPort, uint16_t *remotePort, uint32_t *ipAddress)
 {
     WiconnectResult result;
 
@@ -202,7 +202,7 @@
                 }
             }
 
-            if(strcmp(toks[1], "TCPS") != 0)
+            if(!((type == SOCKET_TYPE_TCP && strcmp(toks[1], "TCPS") == 0) || (type == SOCKET_TYPE_WS && strcmp(toks[1], "WEBS") == 0)))
             {
                 continue;
             }
@@ -220,7 +220,11 @@
             {
                 continue;
             }
-            else if(serverConnectedClientList & handleMask)
+            else if(type == SOCKET_TYPE_TCP && (serverConnectedClientList & handleMask))
+            {
+                continue;
+            }
+            else if(type == SOCKET_TYPE_WS && (websocketConnectedList & handleMask))
             {
                 continue;
             }
@@ -240,7 +244,14 @@
         {
             if(!(connectedClients & mask))
             {
-                serverConnectedClientList &= ~mask;
+                if(type == SOCKET_TYPE_TCP)
+                {
+                    serverConnectedClientList &= ~mask;
+                }
+                else
+                {
+                    websocketConnectedList &= ~mask;
+                }
             }
         }
     }