Closed richard-ash closed 4 years ago
You can override the encode
and decode
closures of the Socket
to provide custom behavior
https://github.com/davidstump/SwiftPhoenixClient/blob/master/Sources/Socket.swift#L86
let socket = Socket(...)
socket.encode = { jsonDictionary in
// convert json dictionary to array data
}
socket.decode = { jsonData in
// convert array data to json dictionary
}
Awesome thanks! 😄
Is there a way to configure
Socket
to be compatible with the Phoenix v2 json serializer?Seems like the diff between v1 & v2 is that v2 uses arrays to encode the message instead of a dictionary, but seems like
Socket
will always send a dictionary