SignalR IOS Client, Web Socket transport cannot invoke the method from server

前端 未结 1 2033
北恋
北恋 2021-02-11 00:35

I m using SignalR-ObjC Client to provide communication between my IOS application and .Net server.

I can connect with longpulling and invoke methods from self-host cros

相关标签:
1条回答
  • 2021-02-11 00:54

    seems to be a problem with the protocol (SRClientTransportInterface) implementation in SRWebSocketTransport.

    Actually is:

    - (void)send:(id <SRConnectionInterface>)connection data:(NSString *)data completionHandler:(void (^)(id response, NSError *error))block;
    

    and must be

    - (void)send:(id <SRConnectionInterface>)connection data:(NSString *)data connectionData:(NSString *)connectionData completionHandler:(void (^)(id response, NSError *error))block; 
    

    Like subclass does not have that implementation is calling superclass (SRHttpBasedTransport) method and for that reason you got "Request failed:bad request(400)" (is another http request and not websocket).

    To fix just open the file SRWebSocketTransport.m in your Pods project and change the implementation, something like this:

    - (void)send:(id<SRConnectionInterface>)connection data:(NSString *)data connectionData:(NSString *)connectionData completionHandler:(void (^)(id response, NSError *error))block {
        [_webSocket send:data];
    
        if(block) {
            block(nil,nil);
        }
    }
    

    Hope this help.

    pd: just checking github seems to be fixed in feature-2.0.0.beta1 branch

    0 讨论(0)
提交回复
热议问题