1
我是ios開發新手。我試圖實現信號R.我試過,我能夠連接到集線器。但我不知道如何調用一個方法樞紐CheckWebServiceStatus
在signalR中調用集線器方法 - 目標C
我收到錯誤
爲「SRHubProxy」不可見@interface聲明選擇「調用:」
這裏是我的代碼
#import "ViewController.h"
#import "SignalR.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
SRHubConnection *hubConnection = [SRHubConnection connectionWithURLString:@"https://MY HUB URL HERE/"];
// Create a proxy to the chat service
SRHubProxy *chat = [hubConnection createHubProxy:@"chatHub"];
[chat on:@"addMessage" perform:self selector:@selector(addMessage:)];
// [chat on:@"addMessage" perform:self selector:@selector(addMessage:)];
// Register for connection lifecycle events
[hubConnection setStarted:^{
NSLog(@"Connection Started");
// [connection send:@"CheckWebServiceStatus"];
[chat invoke:@"CheckWebServiceStatus"];
}];
[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);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
有人可以告訴我如何調用使用HUB方法objecti ve c。