MBWebSocketServer icon indicating copy to clipboard operation
MBWebSocketServer copied to clipboard

Server should be able to gracefully close

Open hongkongkiwi opened this issue 13 years ago • 1 comments

Needs a close method to stop the server gracefully. If this is not done and the object is just set to nil then the clients continue to stay connected.

I propose something like the following.

// MBWebSocketServer.h
- (void)closeServer;

// MBWebSocketServer.m
- (void)closeServer {
    _port = 0;
    _delegate = nil;
    [socket setDelegate:nil];
    [socket disconnect];
    [connections removeAllObjects];

    NSError *error = nil;
}

hongkongkiwi avatar Dec 18 '12 01:12 hongkongkiwi

Agreed. PR welcome, or I will get round to this next time I hack on this code. Can't give date for that.

mxcl avatar Jan 09 '13 16:01 mxcl