TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Sep 2016 |
SPMSupports SPM | ✗ |
Maintained by Yaxin Cheng.
A wrapped Swift toolkit for socket connection
SocketKit can be installed through Cocoapods or manual import.
Kit imports
import SocketKit
The only class will be used in the kit. All the requests go from this kit.
public init(address: String, port: Int) throws { ... }
SocketError.connectionFailed may be thrown from the constructor when connection failed
public func read(complete: @escaping (String?) -> Void) throws { ... }
This function accepts a call back closure, which will be called when value is read from socket server side
The closure accepts an optional string, and may throw out a SocketError.notConnected if the socket lost connection
public func write(value: String) throws { ... }
This function accepts an UTF-8 string value, and encode the string to binary data, then write to the socket server.
SocketError.notConnected may be thrown if the socket connection is lost
SocketError.notWritable may be thrown if the socket is not allowed to write values
SocketError.dataEncodingFailed may be thrown if the string value cannot be encoded
public var isConnected: Bool
This attribute returns true if the socket is connected, otherwise false
WeatherKit is released under the MIT license. See LICENSE for details.