SocketData
public protocol SocketData
A marking protocol that says a type can be represented in a socket.io packet.
Example:
struct CustomData : SocketData {
let name: String
let age: Int
func socketRepresentation() -> SocketData {
return ["name": name, "age": age]
}
}
socket.emit("myEvent", CustomData(name: "Erik", age: 24))
-
socketRepresentation()
Default implementationA representation of self that can sent over socket.io.
Default Implementation
Default implementation. Only works for native Swift types and a few Foundation types.
Declaration
Swift
func socketRepresentation() throws -> SocketData