mirek / CoreWebSocket

Web Socket Server and Client Library for iOS and OSX. Follows Core Foundation API style.
http://en.wikipedia.org/wiki/WebSockets
142 stars 34 forks source link

WebSockets connection won't close. #12

Closed michielboekhoff closed 2 years ago

michielboekhoff commented 9 years ago

Using https://www.websocket.org/echo.html and running the example on my MacBook Pro, the connection will refuse to close.

AppDelegate.m:

#import "AppDelegate.h"
#include "CoreWebSocket/CoreWebSocket.h"

@interface AppDelegate ()

@property (weak) IBOutlet NSWindow *window;
@end

@implementation AppDelegate

 void Callback(WebSocketRef self, WebSocketClientRef client, CFStringRef value) {
    if (value) {
        CFShow(value);
        WebSocketWriteWithString(self, CFSTR("hello!"));
    }
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    // Insert code here to initialize your application
    WebSocketRef webSocket = WebSocketCreateWithHostAndPort(NULL, kWebSocketHostAny,     6001, NULL);
    if (webSocket) {
        webSocket->callbacks.didClientReadCallback = Callback;
    }
}

- (void)applicationWillTerminate:(NSNotification *)aNotification {
    // Insert code here to tear down your application
}

@end

I tried, and the callback willRemoveClientCallback is not called. Any help with this?

Alex.

michielboekhoff commented 9 years ago

I see pull request #10 fixes part of this problem! Is anyone going to merge that? Right now, the only thing that needs to be done is sending a close frame.

michielboekhoff commented 9 years ago

I forked the repo and merged the changes with #10 (more or less).

michielboekhoff commented 2 years ago

Closed as this is very old.