信号 R - 获取第二个参数
Signal R - get the second parameter
嗨,我是 Objective C 和 ios
的新手
我正在使用这个 [signal R 库][1]
开发一个聊天应用程序
我可以毫无问题地连接和调用 successFully。但我的问题是,我正在订阅一个集线器方法 newVisitorNotification 就像这样。
[chat on:@"newVisitorNotification" perform:self selector:@selector(responsenewVisitorNotification:)];
当新消息到达 newVisitorNotification 时,它会将数据发送到 responsenewVisitorNotification
。此方法发送两个参数
2016-12-30 12:21:52.389411 Chat System[451:79343] CONNECTION: connection did receive data {
A = (
"6279b7ce-20bf-40f7-b8e8-8f987e209fbf",
baman26
);
H = ChatHub;
M = newVisitorNotification;
}
但是我的方法只能接收一个参数
-(void) responsenewVisitorNotification:(NSString *) response {
NSLog(@"Inside response incomming chat");
NSLog(@"Response incomming Chat : %@", response);
}
谁能帮我得到里面的第二个参数responsenewVisitorNotification
.
这是我的完整代码
- (void) StartConnection {
self.CONNECTIONSTATUS = NO;
[self setHubEnvironmentURL];
hubConnection = [SRHubConnection connectionWithURLString:environmentURL];
chat = [hubConnection createHubProxy:@"chatHub"];
[chat on:@"serviceStatus" perform:self selector:@selector(getServiceStaus:)];
[chat on:@"newVisitorNotification" perform:self selector:@selector(responsenewVisitorNotification:)];
// Register for connection lifecycle events
[hubConnection setStarted:^{
NSLog(@"Connection Started ");
NSLog(@"**************************************************************************");
NSLog(@"****************************** Starting Invoke ***************************");
NSLog(@"**************************************************************************");
[self invokeIncommingChats:ProfileId Company:companyId Token:profileToken];
self.CONNECTIONSTATUS = YES;
}];
[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)getServiceStaus:(NSString *)message {
NSLog(@"Service Status : %@", message);
}
-(void) responsenewVisitorNotification:(NSString *) response {
NSLog(@"Inside response incomming chat");
NSLog(@"Response incomming Chat : %@", response);
}
[1]: https://github.com/DyKnow/SignalR-ObjC
你的selector
不对。 Read this.
[chat on:@"newVisitorNotification" perform:self
//selector:@selector(responsenewVisitorNotification::)]
selector:@selector(responsenewVisitorNotification:and:)]
然后:
-(void) responsenewVisitorNotification:(NSString *) response1 :(NSString*)response2 {
NSLog(@"Inside response incomming chat");
NSLog(@"Response field 1 incomming Chat : %@", response1);
NSLog(@"Response field 2 incomming Chat : %@", response2);
}
嗨,我是 Objective C 和 ios
的新手我正在使用这个 [signal R 库][1]
开发一个聊天应用程序我可以毫无问题地连接和调用 successFully。但我的问题是,我正在订阅一个集线器方法 newVisitorNotification 就像这样。
[chat on:@"newVisitorNotification" perform:self selector:@selector(responsenewVisitorNotification:)];
当新消息到达 newVisitorNotification 时,它会将数据发送到 responsenewVisitorNotification
。此方法发送两个参数
2016-12-30 12:21:52.389411 Chat System[451:79343] CONNECTION: connection did receive data {
A = (
"6279b7ce-20bf-40f7-b8e8-8f987e209fbf",
baman26
);
H = ChatHub;
M = newVisitorNotification;
}
但是我的方法只能接收一个参数
-(void) responsenewVisitorNotification:(NSString *) response {
NSLog(@"Inside response incomming chat");
NSLog(@"Response incomming Chat : %@", response);
}
谁能帮我得到里面的第二个参数responsenewVisitorNotification
.
这是我的完整代码
- (void) StartConnection {
self.CONNECTIONSTATUS = NO;
[self setHubEnvironmentURL];
hubConnection = [SRHubConnection connectionWithURLString:environmentURL];
chat = [hubConnection createHubProxy:@"chatHub"];
[chat on:@"serviceStatus" perform:self selector:@selector(getServiceStaus:)];
[chat on:@"newVisitorNotification" perform:self selector:@selector(responsenewVisitorNotification:)];
// Register for connection lifecycle events
[hubConnection setStarted:^{
NSLog(@"Connection Started ");
NSLog(@"**************************************************************************");
NSLog(@"****************************** Starting Invoke ***************************");
NSLog(@"**************************************************************************");
[self invokeIncommingChats:ProfileId Company:companyId Token:profileToken];
self.CONNECTIONSTATUS = YES;
}];
[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)getServiceStaus:(NSString *)message {
NSLog(@"Service Status : %@", message);
}
-(void) responsenewVisitorNotification:(NSString *) response {
NSLog(@"Inside response incomming chat");
NSLog(@"Response incomming Chat : %@", response);
}
[1]: https://github.com/DyKnow/SignalR-ObjC
你的selector
不对。 Read this.
[chat on:@"newVisitorNotification" perform:self
//selector:@selector(responsenewVisitorNotification::)]
selector:@selector(responsenewVisitorNotification:and:)]
然后:
-(void) responsenewVisitorNotification:(NSString *) response1 :(NSString*)response2 {
NSLog(@"Inside response incomming chat");
NSLog(@"Response field 1 incomming Chat : %@", response1);
NSLog(@"Response field 2 incomming Chat : %@", response2);
}