SnareHanger
SnareHanger

Reputation: 928

SignalR-ObjC not invoking server calls

I'm trying to setup SignalR-ObjC in an iOS app. I've already tested calls from the server to the client with no problems. I have yet to get the invoke method to work.

Here's where I'm setting up the hub Connection

-(void)setupHubConnection{
   hubConnection = [SRHubConnection connectionWithURL:@"http://hostname/Janus.Web/"];
   janus = [hubConnection createHubProxy:@"syncHub"];

   [janus on:@"picture" perform:self selector:@selector(checkStuff:)];
   [janus on:@"registrationResponse" perform:self selector:@selector(gotRegistered:)];

   [hubConnection start];

   [self registerDevice];
}

and here's where I'm invoking the server call

-(void)registerDevice{
    NSString *os = [NSString stringWithFormat:@"%@%@", [[UIDevice currentDevice] systemName], [[UIDevice currentDevice] systemVersion]];
    NSString *jsonRegister = [NSString stringWithFormat:@"{\"ClientDeviceModel\": {\"ClientID\": \"%@\",\"HardwareInfo\": \"%@\",\"OS\": \"%@\",\"AppVersion\": \"%@\",\"MessageID\": %@}}", [[UIDevice currentDevice] name], [[UIDevice currentDevice]model], os, [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"], [NSString stringWithFormat:@"%.0f", [NSDate timeIntervalSinceReferenceDate]]];

    NSLog(@"%@", jsonRegister);

    NSMutableArray *registerInfo = [[NSMutableArray alloc] init];
    [registerInfo addObject:jsonRegister];

    [janus invoke:@"RegisterClient" withArgs:registerInfo completionHandler:^(id response){
        NSLog(@"%@", response);
    }];
}

I haven't seen anything hit the server from this invoke RegisterClient call.

Any ideas?

Upvotes: 2

Views: 2596

Answers (1)

SnareHanger
SnareHanger

Reputation: 928

Figured it out. I was trying to call registerDevice right after calling [hubConnection start]. Instead, now, I'm using this:

-(void)SRConnectionDidOpen:(SRHubConnection*)connection{
    [self registerDevice];
}

and setting the connection delegate to self.

Upvotes: 3

Related Questions