1

Hi iam new to Objective C and ios

I am developing a chat application using this [signal R library][1]

I am able to connect and invoke successFully without any issue. But my problem is, I am subscribing to a hub method newVisitorNotification Like this.

[chat on:@"newVisitorNotification" perform:self selector:@selector(responsenewVisitorNotification:)];

When an a new message comes to newVisitorNotification it will send the data to responsenewVisitorNotification . This method sends Two Parameters

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;
}

but my method can receive only one parameter.

-(void) responsenewVisitorNotification:(NSString *) response {
    NSLog(@"Inside response incomming chat");
    NSLog(@"Response incomming Chat : %@", response);
}

Can someone help me to get the second parameter inside responsenewVisitorNotification.

here is my full code

- (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
Sathya Baman
  • 3,424
  • 7
  • 44
  • 77

1 Answers1

1

Your selector is not right. Read this.

[chat on:@"newVisitorNotification" perform:self      
//selector:@selector(responsenewVisitorNotification::)]
selector:@selector(responsenewVisitorNotification:and:)]

and then:

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

 }
Community
  • 1
  • 1
SHN
  • 785
  • 7
  • 23