File tree Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Expand file tree Collapse file tree 2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ final class CallbackManager: Sendable {
124124 }
125125 return nil
126126 }
127- let callbacks = broadcastCallbacks. filter { $0. event == event }
127+ let callbacks = broadcastCallbacks. filter { $0. event == " * " || $0 . event. lowercased ( ) == event . lowercased ( ) }
128128 callbacks. forEach { $0. callback ( json) }
129129 }
130130
Original file line number Diff line number Diff line change @@ -187,14 +187,29 @@ final class CallbackManagerTests: XCTestCase {
187187
188188 let jsonObject = try JSONObject ( message)
189189
190+ // Match exact event
190191 let receivedMessage = LockIsolated < JSONObject ? > ( nil )
191192 callbackManager. addBroadcastCallback ( event: event) {
192193 receivedMessage. setValue ( $0)
193194 }
194-
195195 callbackManager. triggerBroadcast ( event: event, json: jsonObject)
196-
197196 XCTAssertEqual ( receivedMessage. value, jsonObject)
197+
198+ // Match event case-insensitive
199+ let caseInsensitiveMessage = LockIsolated < JSONObject ? > ( nil )
200+ callbackManager. addBroadcastCallback ( event: event) {
201+ caseInsensitiveMessage. setValue ( $0)
202+ }
203+ callbackManager. triggerBroadcast ( event: " NEW_USER " , json: jsonObject)
204+ XCTAssertEqual ( caseInsensitiveMessage. value, jsonObject)
205+
206+ // Match any events with wildcard
207+ let wildcardReceivedMessage = LockIsolated < JSONObject ? > ( nil )
208+ callbackManager. addBroadcastCallback ( event: " * " ) {
209+ wildcardReceivedMessage. setValue ( $0)
210+ }
211+ callbackManager. triggerBroadcast ( event: event, json: jsonObject)
212+ XCTAssertEqual ( wildcardReceivedMessage. value, jsonObject)
198213 }
199214
200215 func testTriggerPresenceDiffs( ) {
You can’t perform that action at this time.
0 commit comments