From f873a22599438973afb6267fa5c1f316c044583a Mon Sep 17 00:00:00 2001 From: Ben Lower Date: Thu, 14 Nov 2024 16:08:13 -0700 Subject: [PATCH] fix message sending --- Sources/Ultravox/Ultravox.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Sources/Ultravox/Ultravox.swift b/Sources/Ultravox/Ultravox.swift index 825c032..320f657 100644 --- a/Sources/Ultravox/Ultravox.swift +++ b/Sources/Ultravox/Ultravox.swift @@ -421,15 +421,14 @@ private final class WebSocketConnection: NSObject, Sendable { case let .data(messageData): print("Unexpected data message") return nil - + case let .string(text): guard let data = text.data(using: .utf8), let message = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] else { return nil } guard message["type"] as? String == "room_info" else { return nil } - guard let roomInfo = message["room_info"] as? [String: Any] else { return nil } - guard let roomUrl = roomInfo["roomUrl"] as? String else { return nil } - guard let token = roomInfo["token"] as? String else { return nil } + guard let roomUrl = message["roomUrl"] as? String else { return nil } + guard let token = message["token"] as? String else { return nil } return RoomInfoMessage(roomUrl: roomUrl, token: token) - + @unknown default: print("Unexpected message type") return nil