Socket 客户端 SocketIOCocoa
- 授权协议: MIT
- 开发语言: Swift
- 操作系统: OS X
- 软件首页: https://github.com/shuoli84/SocketIOCocoa
- 软件文档: https://github.com/shuoli84/SocketIOCocoa
软件介绍
SocketIOCocoa 是用 Swift 编写的 Socket.IO 的客户端开发包。同时也提供 Objective-C 版本。
示例代码:
创建客户端:
var client = SocketIOClient(uri: uri, reconnect: true, timeout: 30) client.open()
创建 Socket
var socket = client.socket("namespace")// Set a delegate on socket
SocketIOSocketDelegate
@objc public protocol SocketIOSocketDelegate {
// Called when the socket received a low level packet
optional func socketOnPacket(socket: SocketIOSocket, packet: SocketIOPacket)
// Called when the socket received an event
func socketOnEvent(socket: SocketIOSocket, event: String, data: AnyObject?)
// Called when the socket is open
func socketOnOpen(socket: SocketIOSocket)
// Called when the socket is on error
func socketOnError(socket: SocketIOSocket, error: String, description: String?)
}
发送消息:
socket.event("message", data: [1,2,3]) { (packet) -> Void in
expectation.fulfill()
}
self.waitForExpectationsWithTimeout(300, handler: nil)
APIs
Daniel Jacobson、Greg Brail、Dan Woods / O'Reilly Media / 2011-12-24 / USD 24.99
Many of the highest traffic sites get more than half of their traffic not through the browser but through the APIs they have created. Salesforce.com (more than 50%) and Twitter (more than 75% fall int......一起来看看 《APIs》 这本书的介绍吧!
