DyKnow / SignalR-ObjC

Objective-C Client for the SignalR Project works with iOS and Mac
MIT License
442 stars 213 forks source link

Joining group undocumented? #284

Closed arcade16 closed 7 years ago

arcade16 commented 7 years ago

I'm looking to figure out how to correctly join groups as SignalR-ObjectiveC is not very well documented. I have set up my application to communicate via SignalR in the following way:

-(void)ConnectSignalR{

    // Connect to the service
    SRHubConnection *hubConnection = [SRHubConnection connectionWithURLString:@"xxx"];

    // Register for connection lifecycle events
    [hubConnection setStarted:^{
        NSLog(@"Connection Started");
    }];
    [hubConnection setReceived:^(NSString *message) {
        NSLog(@"Connection Recieved Data: %@",message);
    }];
    [hubConnection setConnectionSlow:^{
        NSLog(@"Connection Slow");
    }];
    [hubConnection setReconnecting:^{
        NSLog(@"Connection Reconnecting");
    }];
    [hubConnection setReconnected:^{
        NSLog(@"Connection Reconnected");
    }];
    [hubConnection setClosed:^{
        NSLog(@"Connection Closed");
    }];
    [hubConnection setError:^(NSError *error) {
        NSLog(@"Connection Error %@",error);
    }];
    // Start the connection
    [hubConnection start];
}

- (void)addMessage:(NSString *)message {
    // Print the message when it comes in
    NSLog(@"%@", message);
}

I then call these methods by doing the following in my main view controller:

-(void)SignalR{

    WebServices *services = [[WebServices alloc] init];

    [services ConnectSignalR];

    [services callGetSRGroupNames:^(NSMutableArray *resultsArray) {
        NSLog(@"SR GROUP NAMES: %@", resultsArray);

        SRHubConnection *hubConnection = [SRHubConnection connectionWithURLString:@"xxx"];

        int i;
        for (i = 0; i < [resultsArray count]; i++) {
            [hubConnection setGroupsToken:resultsArray[i]];
        }
    }];
}

Is this correct? The output I get is: WS: websocket did receive: {"C":"s-0,94445","S":1,"M":[]}