2
我想在iOS應用程序中設置SignalR-ObjC。我已經測試了從服務器到客戶端的呼叫,沒有任何問題。我還沒有得到invoke方法的工作。SignalR-ObjC不調用服務器調用
這裏就是我設立樞紐連接
-(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調用。
任何想法?
我在調查這個完全相同的問題約5個小時才找到這篇文章。 +1,感謝您解決這個問題,SignalR iOS文檔不是很有幫助。 – Jsdodgers