Lab2_web / Mbed 2 deprecated webserverBlinky

Dependencies:   mbed

Fork of webserverBlinky by RealTimeCompLab2

Files at this revision

API Documentation at this revision

Comitter:
nixnax
Date:
Mon Aug 14 10:50:31 2017 +0000
Parent:
130:45ee0d648a72
Child:
132:09b66cc5cf4a
Commit message:
Graceful WebSocket close.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Aug 14 04:40:02 2017 +0000
+++ b/main.cpp	Mon Aug 14 10:50:31 2017 +0000
@@ -39,7 +39,7 @@
 #include "mbed.h"
 #include "sha1.h"
 #include "BufferedSerial.h"
- 
+
 // The #define below enables/disables a second (OPTIONAL) serial port that prints out interesting diagnostic messages.
 // Change to SERIAL_PORT_MONITOR_YES to enable diagnostics messages. You need to wire a second serial port to your mbed hardware to monitor this.
 // Note - the LPC11U24 does NOT have a second serial port
@@ -742,7 +742,7 @@
             n=n+sprintf(n+dataStart,"<body>%d</body>",ppp.httpPageCount); // body = the http frame count
 #else
 #define BENCHMARK_USING_BROWSER_NO /* set to _YES if you want to use your browser as a benchmark tool */
-#ifndef BENCHMARK_USING_BROWSER_NO
+#ifdef BENCHMARK_USING_BROWSER_YES
             // semd a small browser script that will reload the page after 10 ms - handy for benchmarking with your web browser, use http://172.10.10.2/x
             n=n+sprintf(n+dataStart, "<script>setTimeout(function(){location.reload();},10);</script><body>%d</body>",ppp.httpPageCount);
 #else
@@ -786,7 +786,8 @@
             n = len; // our response size remains exactly the same length as what we received
         }
     } else if ( (dataStart[0]==0x88) && (dataStart[1]==0x80) && (len == 6) ) { // test for a websocket close request
-        *outFlags |= TCP_FLAG_FIN; // set the fin flag to close the websocket request
+        n=2; // our close command is only two bytes long because we don't use the four mask bytes
+        dataStart[1]=0; // we don't have mask bytes on
     } else if (v1) putsWhileCheckingInput("TCP data received\n");
     return n; // total byte size of our response
 }