Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit adds some important improvements to the websocket server - The websocket can now handled framing. Websockets have a maximum frame size, if a message is larger than that it will be split into multiple frames (which, in turn, might be split into multiple chunks each). Previously, the webserver would call the onMessage callback on every chunk. Now, the server gathers the entire message first and then calls the onMessage callback for the entire message. - The WS server now calls libwebsocket_callback_on_writable instead of libwebsocket_callback_on_writable_all_protocol where appropiate - A little refactoring where we added BLWebsocketConnection that gathers everything related to a single WS connection - CWWebServer has been refactored so the websocket callbacks are more readable
- Loading branch information
Mario Schreiner
committed
Jan 23, 2015
1 parent
0baf165
commit b7b7ca0
Showing
7 changed files
with
210 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// BLWebSocket.h | ||
// Connichiwa | ||
// | ||
// Created by Mario Schreiner on 23/01/15. | ||
// Copyright (c) 2015 Mario Schreiner. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "BLWebSocketsServer.h" | ||
#import "libwebsockets.h" | ||
|
||
|
||
|
||
@interface BLWebSocketConnection : NSObject | ||
|
||
@property (readonly) int ID; | ||
@property (readonly) struct libwebsocket *socket; | ||
@property (readwrite, copy) BLWebSocketsHandleRequestBlock handleRequestBlock; | ||
@property (readwrite, strong) NSMutableData *currentMessage; | ||
|
||
- (instancetype)initWithID:(int)ID socket:(struct libwebsocket *)socket; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// BLWebSocket.m | ||
// Connichiwa | ||
// | ||
// Created by Mario Schreiner on 23/01/15. | ||
// Copyright (c) 2015 Mario Schreiner. All rights reserved. | ||
// | ||
|
||
#import "BLWebSocketConnection.h" | ||
|
||
|
||
|
||
@interface BLWebSocketConnection() | ||
|
||
@property (readwrite) int ID; | ||
@property (readwrite) struct libwebsocket *socket; | ||
|
||
@end | ||
|
||
@implementation BLWebSocketConnection | ||
|
||
- (instancetype)initWithID:(int)ID socket:(struct libwebsocket *)socket { | ||
self = [super init]; | ||
|
||
self.ID = ID; | ||
self.socket = socket; | ||
|
||
return self; | ||
} | ||
|
||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.