mirror of https://github.com/oxen-io/session-ios
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
961 B
Swift
29 lines
961 B
Swift
|
|
extension CallVCV2 : WebSocketDelegate {
|
|
|
|
func webSocketDidConnect(_ webSocket: WebSocket) {
|
|
guard let room = room else { return }
|
|
let json = [
|
|
"cmd" : "register",
|
|
"roomid" : room.roomID,
|
|
"clientid" : room.clientID
|
|
]
|
|
guard let data = try? JSONSerialization.data(withJSONObject: json, options: [ .prettyPrinted ]) else { return }
|
|
print("[Calls] Web socket connected. Sending: \(json).")
|
|
webSocket.send(data)
|
|
print("[Calls] Is initiator: \(room.isInitiator).")
|
|
if room.isInitiator {
|
|
callManager.initiateCall().retainUntilComplete()
|
|
}
|
|
}
|
|
|
|
func webSocketDidDisconnect(_ webSocket: WebSocket) {
|
|
webSocket.delegate = nil
|
|
}
|
|
|
|
func webSocket(_ webSocket: WebSocket, didReceive message: String) {
|
|
print("[Calls] Message received through web socket: \(message).")
|
|
handle([ message ])
|
|
}
|
|
}
|