Skip to content

Commit 1c2d5db

Browse files
committed
Handling multiple connections by dropping the old one, when a new request arrives.
1 parent 89f9b1d commit 1c2d5db

File tree

9 files changed

+12
-3
lines changed

9 files changed

+12
-3
lines changed

Base64.cpp

100644100755
File mode changed.

Base64.h

100644100755
File mode changed.

README.md

100644100755
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The implementation in this library has restrictions as the Arduino platform reso
88
* The server **only** handles **single byte** chars. The Arduino just can't handle UTF-8 to it's full.
99
* The server **only** accepts **final** frames with maximum payload length of 64 bytes. No fragmented data, in other words.
1010
* For now, the server silently ignores all frames except TXT and CLOSE.
11-
* The server **only** handles one client at a time. Trying to connect two at the same time will ruin your day.
11+
* The server **only** handles one client at a time. Trying to connect two at the same time will force the old client to disconnect.
1212
* There's no keep-alive logic implemented.
1313

1414
_Required headers (example):_

WebSocket.cpp

100644100755
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
//#define DEBUG
66

7+
8+
79
struct Frame {
810
bool isMasked;
911
bool isFinal;
@@ -32,9 +34,11 @@ void WebSocket::begin() {
3234

3335

3436
void WebSocket::listen() {
35-
if (client = server.available()) {
36-
if (client == true) {
37+
EthernetClient cli;
38+
if (cli = server.available()) {
39+
if (cli == true) {
3740
if (state == DISCONNECTED ) {
41+
client = cli;
3842
if (doHandshake() == true) {
3943
state = CONNECTED;
4044
if (onConnect) {
@@ -220,6 +224,7 @@ bool WebSocket::getFrame() {
220224
#ifdef DEBUG
221225
Serial.println("Unhandled frame ignored.");
222226
#endif
227+
return false;
223228
break;
224229
}
225230
return true;

WebSocket.h

100644100755
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ THE SOFTWARE.
3333
-------------
3434
Now based off version 13
3535
http://datatracker.ietf.org/doc/rfc6455/?include_text=1
36+
37+
Modified by Alexandros Baltas, 2013
38+
www.codebender.cc
39+
3640
*/
3741

3842
#include <Arduino.h> // Arduino 1.0 or greater is required

examples/Websocket_Demo/Websocket_Demo.ino

100644100755
File mode changed.

sha1.cpp

100644100755
File mode changed.

sha1.h

100644100755
File mode changed.

websocket.html

100644100755
File mode changed.

0 commit comments

Comments
 (0)