2

我正在实施:

@protocol SRWebSocketDelegate <NSObject>

- (void)webSocket:(SRWebSocket *)webSocket didReceiveMessage:(id)message;

@optional

- (void)webSocketDidOpen:(SRWebSocket *)webSocket;
- (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error;
- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean;

在斯威夫特。我可以实现的所有功能都可以正常工作,但didCloseWithCode我无法让它工作。

我在实施时遇到问题

- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean;

在斯威夫特。

我在尝试:

func webSocket(webSocket: SRWebSocket!, didCloseWithCode code: NSInteger!, reason: NSString!, wasClean: Bool!) {
    println("websocket closed: \(reason)")
    self.connect(5.0)
}

没有运气。

4

1 回答 1

0
func webSocketDidOpen(webSocket: SRWebSocket!) {
    DDLogInfo("socket opened");
}

func webSocket(webSocket: SRWebSocket!, didCloseWithCode code: Int, reason: String!, wasClean: Bool) {
    DDLogError("code: \(code) reason:\(reason) ");
}

func webSocket(webSocket: SRWebSocket!, didFailWithError error: NSError!) {
    DDLogError("error: \(error)");
}

func webSocket(webSocket: SRWebSocket!, didReceiveMessage message: AnyObject!) {
}
于 2015-12-28T10:15:05.617 回答