| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
m45y
9年前发布

WebSocket 客户端库:SwiftWebSocket

SwiftWebSocket 是高性能的 WebSocket 客户端库。

特性:

  • Pure Swift solution. No need for Objective-C Bridging.

  • Reads compressed messages (permessage-deflate). IETF Draft

  • Strict UTF-8 processing.

  • The API is modeled after the Javascript API.

  • TLS / WSS support.

  • binaryTypeproperty to choose between[UInt8]orNSDatamessages.

  • Zero asserts. All networking, stream, and protocol errors are routed through theerrorevent.

  • Send pings and receive pong events.

  • High performance.

例子:

func echoTest(){      var messageNum = 1      var ws = WebSocket(url: "wss://echo.websocket.org")      var send : ()->() = {          var msg = "#\(messageNum++): \(NSDate().description)"          println("send: \(msg)")          ws.send(msg)      }      ws.event.open = {          println("opened")          send()      }      ws.event.close = { (code, reason, clean) in          println("close")      }      ws.event.error = { (error) in          println("error \(error.localizedDescription)")      }      ws.event.message = { (message) in          if let text = message as? String {              println("recv: \(text)")              send()          }      }  }

项目主页:http://www.open-open.com/lib/view/home/1433145778150

 本文由用户 m45y 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1433145778150.html
WebSocket 开发 SwiftWebSocket