SignalR-ObjC不调用服务器调用

时间:2013-08-02 18:46:50

标签: ios objective-c signalr

我正在尝试在iOS应用中设置SignalR-ObjC。我已经测试了从服务器到客户端的调用没有问题。我还没有让invoke方法起作用。

这是我正在设置集线器连接

的地方
-(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];
}

这是我调用服务器调用的地方

-(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);
    }];
}

我没有看到任何来自此调用RegisterClient调用的服务器。

有什么想法吗?

1 个答案:

答案 0 :(得分:3)

想出来。我在调用[hubConnection start]后试图立即调用registerDevice。相反,现在,我正在使用它:

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

并将连接委托设置为self。