当前位置 博文首页 > dengren1956的博客:基于Facebook开源框架SocketRocket的即时通
SocketRocket 介绍:
SocketRock 是 Facebook 开源的框架,基于 WebSocket 客户端类库,适用于 iOS、Mac OS、tv OS。GitHub 传送门:https://github.com/facebook/SocketRocket
安装:pod 'SocketRocket'
也可以拖入文件?SocketRocket:
引入框架:
SocketRocket 初始化:
- (void)initSocket { if (webSocket) { return; } webSocket = [[SRWebSocket alloc] initWithURL:[NSURL URLWithString:ServerURL]]; webSocket.delegate = self; // 设置代理线程queue NSOperationQueue * queue=[[NSOperationQueue alloc]init]; queue.maxConcurrentOperationCount=1; [webSocket setDelegateOperationQueue:queue]; // 连接 [webSocket open]; }cs