Skip to content
Browse files

Handling multiple connections by dropping the old one, when a new req…

…uest arrives.
  • Loading branch information...
1 parent 89f9b1d commit 1c2d5db27dd628fd57a504f2f5030f20194471d3 @albaltas albaltas committed Apr 8, 2013
View
0 Base64.cpp 100644 → 100755
File mode changed.
View
0 Base64.h 100644 → 100755
File mode changed.
View
2 README.md 100644 → 100755
@@ -8,7 +8,7 @@ The implementation in this library has restrictions as the Arduino platform reso
* The server **only** handles **single byte** chars. The Arduino just can't handle UTF-8 to it's full.
* The server **only** accepts **final** frames with maximum payload length of 64 bytes. No fragmented data, in other words.
* For now, the server silently ignores all frames except TXT and CLOSE.
-* The server **only** handles one client at a time. Trying to connect two at the same time will ruin your day.
+* The server **only** handles one client at a time. Trying to connect two at the same time will force the old client to disconnect.
* There's no keep-alive logic implemented.
_Required headers (example):_
View
9 WebSocket.cpp 100644 → 100755
@@ -4,6 +4,8 @@
//#define DEBUG
+
+
struct Frame {
bool isMasked;
bool isFinal;
@@ -32,9 +34,11 @@ void WebSocket::begin() {
void WebSocket::listen() {
- if (client = server.available()) {
- if (client == true) {
+ EthernetClient cli;
+ if (cli = server.available()) {
+ if (cli == true) {
if (state == DISCONNECTED ) {
+ client = cli;
if (doHandshake() == true) {
state = CONNECTED;
if (onConnect) {
@@ -220,6 +224,7 @@ bool WebSocket::getFrame() {
#ifdef DEBUG
Serial.println("Unhandled frame ignored.");
#endif
+ return false;
break;
}
return true;
View
4 WebSocket.h 100644 → 100755
@@ -33,6 +33,10 @@ THE SOFTWARE.
-------------
Now based off version 13
http://datatracker.ietf.org/doc/rfc6455/?include_text=1
+
+Modified by Alexandros Baltas, 2013
+www.codebender.cc
+
*/
#include <Arduino.h> // Arduino 1.0 or greater is required
View
0 examples/Websocket_Demo/Websocket_Demo.ino 100644 → 100755
File mode changed.
View
0 sha1.cpp 100644 → 100755
File mode changed.
View
0 sha1.h 100644 → 100755
File mode changed.
View
0 websocket.html 100644 → 100755
File mode changed.

0 comments on commit 1c2d5db

Please sign in to comment.
Something went wrong with that request. Please try again.