iOS SocketRocket实现即时通讯

释放双眼,带上耳机,听听看~!

1.可在github上下载,包含了demo和测试地址

https://github.com/facebook/SocketRocket

2.遇到的BUG:

Connection Failed:Error Domain=SRWebSocketErrorDomain
Code=2133 "Invalid Sec-WebSocket-Accept response."
Sec-WebSocket-Accept response.}

解决方法:URL后面添加ws。

3.使用

    //初始化
self.webSocket = [[SRWebSocket alloc] initWithURL:URL];
self.webSocket.delegate = self;
[self.webSocket open];

常用代理方法

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

人已赞赏
APP Store上架研究iOS文章

upload to app Atore 错误信息汇总

2020-2-20 3:31:41

iOS文章

iOS开发Spring Animation动画

2020-2-20 7:27:28

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索