Nethravathitcs / unitt

Automatically exported from code.google.com/p/unitt
0 stars 0 forks source link

WebSocket10 But in close function #18

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Implement WebSocket10 as e.g. myWebSocket
2. call [myWebSocket close]

What is the expected output? What do you see instead?
closed socket connection

What version of the product are you using? On what operating system?
0.9.3.1

Please provide any additional information below.

If I use WebSocket10.m and close on my web socket object it won't be closed; 
seems like the close function calls itself recursively if you try to send a 
close via [mySocket close];

- (void) close
{
    [self close:WebSocketCloseStatusNormal message:nil];
}

- (void) close:(NSUInteger) aStatusCode message:(NSString*) aMessage
{
    readystate = WebSocketReadyStateClosing;
    if ([aMessage canBeConvertedToEncoding:NSUTF8StringEncoding])
    {
        [self sendClose:aStatusCode message:aMessage];
    }
    else
    {
        [self close:WebSocketCloseStatusInvalidUtf8 message:nil];
    }
    isClosing = YES;
}

Instead shouldn't it look like?

- (void) close
{
    [self close:WebSocketCloseStatusNormal message:nil];
}

- (void) close:(NSUInteger) aStatusCode message:(NSString*) aMessage
{
    readystate = WebSocketReadyStateClosing;
    if ([aMessage canBeConvertedToEncoding:NSUTF8StringEncoding])
    {
        [self sendClose:aStatusCode message:aMessage];
    }
    else
    {
        [self sendClose:aStatusCode message:nil];
    }
    isClosing = YES;
}

Original issue reported on code.google.com by andre.moencher@gmail.com on 26 Sep 2011 at 9:02

GoogleCodeExporter commented 8 years ago
Sorry for the type: headline should be "bug in close function"

Original comment by andre.moencher@gmail.com on 26 Sep 2011 at 9:06

GoogleCodeExporter commented 8 years ago
I temporarily changed the code to 
- (void) close
{
    [self close:WebSocketCloseStatusNormal message:nil];
}

- (void) close:(NSUInteger) aStatusCode message:(NSString*) aMessage
{
    readystate = WebSocketReadyStateClosing;
    [self sendClose:aStatusCode message:aMessage];
    isClosing = YES;
}

Original comment by andre.moencher@gmail.com on 26 Sep 2011 at 9:54

GoogleCodeExporter commented 8 years ago
Excellent find! I will get a fix out this week.

Original comment by joshuadmorris@gmail.com on 26 Sep 2011 at 3:03

GoogleCodeExporter commented 8 years ago
Fixed in the trunk, working on other fixes before I do a release.

Original comment by joshuadmorris@gmail.com on 27 Sep 2011 at 9:09

GoogleCodeExporter commented 8 years ago
Great to here … 

Original comment by andre.moencher@gmail.com on 27 Sep 2011 at 9:11

GoogleCodeExporter commented 8 years ago

Original comment by joshuadmorris@gmail.com on 9 Oct 2011 at 2:29