2

I am implementing:

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

in Swift. All functions I can implement ok and works, but didCloseWithCode I just can't make it to work.

I am having trouble implementing

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

in Swift.

I am trying:

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

with no luck.

Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
Karismo
  • 21
  • 1
  • I believe swift converts NSString to String - try changing that? Edit: Same with NSInteger. See http://www.informit.com/articles/article.aspx?p=2344214&seqNum=8 – Mark Jun 21 '15 at 01:08
  • I have already tried that with no luck. – Karismo Jun 21 '15 at 01:22

1 Answers1

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!) {
}
john07
  • 562
  • 6
  • 16