Socket 客户端 SocketIOCocoa

码农软件 · 软件分类 · 网络(Networking) · 2019-07-10 14:57:05

软件介绍

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)

本文地址:https://www.codercto.com/soft/d/9832.html

The Art of Computer Programming, Volume 4,  Fascicle 3

The Art of Computer Programming, Volume 4, Fascicle 3

Donald E. Knuth / Addison-Wesley Professional / 2005-08-05 / USD 19.99

Finally, after a wait of more than thirty-five years, the first part of Volume 4 is at last ready for publication. Check out the boxed set that brings together Volumes 1 - 4A in one elegant case, and ......一起来看看 《The Art of Computer Programming, Volume 4, Fascicle 3》 这本书的介绍吧!

随机密码生成器
随机密码生成器

多种字符组合密码

SHA 加密
SHA 加密

SHA 加密工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器