@livechatta/sdk 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +218 -0
- package/LICENSE +21 -0
- package/README.md +2558 -2
- package/bin/chatta.mjs +7 -0
- package/bin/lib/cli.d.mts +46 -0
- package/bin/lib/cli.mjs +2088 -0
- package/dist/cjs/livechatta.cjs.js +7258 -0
- package/dist/cjs/livechatta.cjs.js.map +1 -0
- package/dist/cjs/livechatta.cjs.min.js +2 -0
- package/dist/cjs/livechatta.cjs.min.js.map +1 -0
- package/dist/esm/livechatta.esm.js +7077 -0
- package/dist/esm/livechatta.esm.js.map +1 -0
- package/dist/esm/livechatta.esm.min.js +2 -0
- package/dist/esm/livechatta.esm.min.js.map +1 -0
- package/dist/platforms/android/LiveChattaClient.kt +367 -0
- package/dist/platforms/android/LiveChattaHttpAPI.kt +2630 -0
- package/dist/platforms/android/LiveChattaJson.kt +83 -0
- package/dist/platforms/android/LiveChattaModels.kt +22805 -0
- package/dist/platforms/android/LiveChattaSentFrom.kt +30 -0
- package/dist/platforms/android/LiveChattaSocketAPI.kt +2113 -0
- package/dist/platforms/android/LiveChattaTyped.kt +239 -0
- package/dist/platforms/android/LiveChattaWebView.kt +158 -0
- package/dist/platforms/angular/livechatta-bridge.service.d.ts +35 -0
- package/dist/platforms/angular/livechatta-bridge.service.js +1 -0
- package/dist/platforms/angular/livechatta-bridge.service.js.map +1 -0
- package/dist/platforms/angular/livechatta-embed.component.d.ts +46 -0
- package/dist/platforms/angular/livechatta-embed.component.js +1 -0
- package/dist/platforms/angular/livechatta-embed.component.js.map +1 -0
- package/dist/platforms/angular/livechatta.service.d.ts +66 -0
- package/dist/platforms/angular/livechatta.service.js +1 -0
- package/dist/platforms/angular/livechatta.service.js.map +1 -0
- package/dist/platforms/capacitor/CapacitorBridge.d.ts +27 -0
- package/dist/platforms/capacitor/CapacitorBridge.js +1 -0
- package/dist/platforms/capacitor/CapacitorBridge.js.map +1 -0
- package/dist/platforms/capacitor/CapacitorDeepLinks.d.ts +23 -0
- package/dist/platforms/capacitor/CapacitorDeepLinks.js +1 -0
- package/dist/platforms/capacitor/CapacitorDeepLinks.js.map +1 -0
- package/dist/platforms/capacitor/CapacitorPermissions.d.ts +29 -0
- package/dist/platforms/capacitor/CapacitorPermissions.js +1 -0
- package/dist/platforms/capacitor/CapacitorPermissions.js.map +1 -0
- package/dist/platforms/capacitor/CapacitorPush.d.ts +33 -0
- package/dist/platforms/capacitor/CapacitorPush.js +1 -0
- package/dist/platforms/capacitor/CapacitorPush.js.map +1 -0
- package/dist/platforms/capacitor/index.d.ts +24 -0
- package/dist/platforms/capacitor/index.js +1 -0
- package/dist/platforms/capacitor/index.js.map +1 -0
- package/dist/platforms/flutter/livechatta_client.dart +359 -0
- package/dist/platforms/flutter/livechatta_http_api.dart +1942 -0
- package/dist/platforms/flutter/livechatta_json.dart +57 -0
- package/dist/platforms/flutter/livechatta_models.dart +23531 -0
- package/dist/platforms/flutter/livechatta_sent_from.dart +35 -0
- package/dist/platforms/flutter/livechatta_socket_api.dart +1504 -0
- package/dist/platforms/flutter/livechatta_typed.dart +234 -0
- package/dist/platforms/flutter/livechatta_webview.dart +190 -0
- package/dist/platforms/ios/LiveChattaClient.swift +374 -0
- package/dist/platforms/ios/LiveChattaHttpAPI.swift +2431 -0
- package/dist/platforms/ios/LiveChattaJSON.swift +84 -0
- package/dist/platforms/ios/LiveChattaModels.swift +27050 -0
- package/dist/platforms/ios/LiveChattaSentFrom.swift +32 -0
- package/dist/platforms/ios/LiveChattaSocketAPI.swift +1446 -0
- package/dist/platforms/ios/LiveChattaTyped.swift +268 -0
- package/dist/platforms/ios/LiveChattaWebView.swift +191 -0
- package/dist/platforms/nuxt/LiveChattaView.d.ts +1 -0
- package/dist/platforms/nuxt/LiveChattaView.js +1 -0
- package/dist/platforms/nuxt/LiveChattaView.js.map +1 -0
- package/dist/platforms/nuxt/useChattaBridge.d.ts +9 -0
- package/dist/platforms/nuxt/useChattaBridge.js +1 -0
- package/dist/platforms/nuxt/useChattaBridge.js.map +1 -0
- package/dist/platforms/nuxt/useLiveChatta.d.ts +63 -0
- package/dist/platforms/nuxt/useLiveChatta.js +1 -0
- package/dist/platforms/nuxt/useLiveChatta.js.map +1 -0
- package/dist/platforms/react/LiveChattaView.d.ts +58 -0
- package/dist/platforms/react/LiveChattaView.js +1 -0
- package/dist/platforms/react/LiveChattaView.js.map +1 -0
- package/dist/platforms/react/useChattaBridge.d.ts +1 -0
- package/dist/platforms/react/useChattaBridge.js +1 -0
- package/dist/platforms/react/useChattaBridge.js.map +1 -0
- package/dist/platforms/react/useChattaDeepLink.d.ts +2 -0
- package/dist/platforms/react/useChattaDeepLink.js +1 -0
- package/dist/platforms/react/useChattaDeepLink.js.map +1 -0
- package/dist/platforms/react/useChattaPermissions.d.ts +9 -0
- package/dist/platforms/react/useChattaPermissions.js +1 -0
- package/dist/platforms/react/useChattaPermissions.js.map +1 -0
- package/dist/platforms/react/useChattaUnread.d.ts +1 -0
- package/dist/platforms/react/useChattaUnread.js +1 -0
- package/dist/platforms/react/useChattaUnread.js.map +1 -0
- package/dist/platforms/react/useLiveChatta.d.ts +29 -0
- package/dist/platforms/react/useLiveChatta.js +1 -0
- package/dist/platforms/react/useLiveChatta.js.map +1 -0
- package/dist/platforms/react-native/LiveChattaView.d.ts +52 -0
- package/dist/platforms/react-native/LiveChattaView.js +1 -0
- package/dist/platforms/react-native/LiveChattaView.js.map +1 -0
- package/dist/platforms/react-native/useChattaBridge.d.ts +12 -0
- package/dist/platforms/react-native/useChattaBridge.js +1 -0
- package/dist/platforms/react-native/useChattaBridge.js.map +1 -0
- package/dist/platforms/react-native/useLiveChatta.d.ts +29 -0
- package/dist/platforms/react-native/useLiveChatta.js +1 -0
- package/dist/platforms/react-native/useLiveChatta.js.map +1 -0
- package/dist/platforms/svelte/LiveChattaEmbed.d.ts +54 -0
- package/dist/platforms/svelte/LiveChattaEmbed.js +1 -0
- package/dist/platforms/svelte/LiveChattaEmbed.js.map +1 -0
- package/dist/platforms/svelte/chattaBridgeStore.d.ts +19 -0
- package/dist/platforms/svelte/chattaBridgeStore.js +1 -0
- package/dist/platforms/svelte/chattaBridgeStore.js.map +1 -0
- package/dist/platforms/svelte/useLiveChatta.d.ts +61 -0
- package/dist/platforms/svelte/useLiveChatta.js +1 -0
- package/dist/platforms/svelte/useLiveChatta.js.map +1 -0
- package/dist/platforms/tauri/TauriBridge.d.ts +34 -0
- package/dist/platforms/tauri/TauriBridge.js +1 -0
- package/dist/platforms/tauri/TauriBridge.js.map +1 -0
- package/dist/platforms/tauri/TauriDeepLinks.d.ts +29 -0
- package/dist/platforms/tauri/TauriDeepLinks.js +1 -0
- package/dist/platforms/tauri/TauriDeepLinks.js.map +1 -0
- package/dist/platforms/tauri/TauriPermissions.d.ts +21 -0
- package/dist/platforms/tauri/TauriPermissions.js +1 -0
- package/dist/platforms/tauri/TauriPermissions.js.map +1 -0
- package/dist/platforms/tauri/TauriUpdater.d.ts +31 -0
- package/dist/platforms/tauri/TauriUpdater.js +1 -0
- package/dist/platforms/tauri/TauriUpdater.js.map +1 -0
- package/dist/platforms/tauri/index.d.ts +22 -0
- package/dist/platforms/tauri/index.js +1 -0
- package/dist/platforms/tauri/index.js.map +1 -0
- package/dist/platforms/vue/LiveChattaView.d.ts +1 -0
- package/dist/platforms/vue/LiveChattaView.js +1 -0
- package/dist/platforms/vue/LiveChattaView.js.map +1 -0
- package/dist/platforms/vue/useChattaBridge.d.ts +11 -0
- package/dist/platforms/vue/useChattaBridge.js +1 -0
- package/dist/platforms/vue/useChattaBridge.js.map +1 -0
- package/dist/platforms/vue/useChattaDeepLink.d.ts +2 -0
- package/dist/platforms/vue/useChattaDeepLink.js +1 -0
- package/dist/platforms/vue/useChattaDeepLink.js.map +1 -0
- package/dist/platforms/vue/useChattaPermissions.d.ts +9 -0
- package/dist/platforms/vue/useChattaPermissions.js +1 -0
- package/dist/platforms/vue/useChattaPermissions.js.map +1 -0
- package/dist/platforms/vue/useChattaUnread.d.ts +8 -0
- package/dist/platforms/vue/useChattaUnread.js +1 -0
- package/dist/platforms/vue/useChattaUnread.js.map +1 -0
- package/dist/platforms/vue/useLiveChatta.d.ts +58 -0
- package/dist/platforms/vue/useLiveChatta.js +1 -0
- package/dist/platforms/vue/useLiveChatta.js.map +1 -0
- package/dist/platforms/web/LiveChattaEmbed.d.ts +94 -0
- package/dist/platforms/web/LiveChattaEmbed.js +1 -0
- package/dist/platforms/web/LiveChattaEmbed.js.map +1 -0
- package/dist/platforms/web/bridge.d.ts +8 -0
- package/dist/platforms/web/bridge.js +1 -0
- package/dist/platforms/web/bridge.js.map +1 -0
- package/dist/platforms/web/permissions.d.ts +8 -0
- package/dist/platforms/web/permissions.js +1 -0
- package/dist/platforms/web/permissions.js.map +1 -0
- package/dist/types/billing.d.ts +355 -0
- package/dist/types/billing.js +53 -0
- package/dist/types/billing.js.map +1 -0
- package/dist/types/calendar.d.ts +132 -0
- package/dist/types/calendar.js +15 -0
- package/dist/types/calendar.js.map +1 -0
- package/dist/types/chat-core.d.ts +901 -0
- package/dist/types/chat-core.js +98 -0
- package/dist/types/chat-core.js.map +1 -0
- package/dist/types/chat-features.d.ts +775 -0
- package/dist/types/chat-features.js +50 -0
- package/dist/types/chat-features.js.map +1 -0
- package/dist/types/content.d.ts +138 -0
- package/dist/types/content.js +2 -0
- package/dist/types/content.js.map +1 -0
- package/dist/types/core/AutoRefresh.d.ts +68 -0
- package/dist/types/core/Bridge.d.ts +124 -0
- package/dist/types/core/Config.d.ts +26 -0
- package/dist/types/core/DeepLinks.d.ts +38 -0
- package/dist/types/core/EventBus.d.ts +15 -0
- package/dist/types/core/GrantStore.d.ts +29 -0
- package/dist/types/core/LiveChatta.d.ts +128 -0
- package/dist/types/core/Permissions.d.ts +34 -0
- package/dist/types/core/TokenManager.d.ts +25 -0
- package/dist/types/core/events.d.ts +140 -0
- package/dist/types/csat.d.ts +110 -0
- package/dist/types/csat.js +12 -0
- package/dist/types/csat.js.map +1 -0
- package/dist/types/events.d.ts +242 -0
- package/dist/types/events.js +275 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/extras.d.ts +353 -0
- package/dist/types/extras.js +31 -0
- package/dist/types/extras.js.map +1 -0
- package/dist/types/http/HttpAPI.d.ts +944 -0
- package/dist/types/http/HttpTransport.d.ts +66 -0
- package/dist/types/http/incomingWebhook.d.ts +17 -0
- package/dist/types/incoming-webhooks.d.ts +78 -0
- package/dist/types/incoming-webhooks.js +16 -0
- package/dist/types/incoming-webhooks.js.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.js +16 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/liveflex.d.ts +578 -0
- package/dist/types/liveflex.js +7 -0
- package/dist/types/liveflex.js.map +1 -0
- package/dist/types/models.d.ts +1753 -0
- package/dist/types/models.js +148 -0
- package/dist/types/models.js.map +1 -0
- package/dist/types/options.d.ts +190 -0
- package/dist/types/options.js +43 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/shared-channels.d.ts +236 -0
- package/dist/types/shared-channels.js +50 -0
- package/dist/types/shared-channels.js.map +1 -0
- package/dist/types/socket/SocketAPI.d.ts +1026 -0
- package/dist/types/socket/SocketTransport.d.ts +44 -0
- package/dist/types/types/billing.d.ts +355 -0
- package/dist/types/types/calendar.d.ts +132 -0
- package/dist/types/types/chat-core.d.ts +901 -0
- package/dist/types/types/chat-features.d.ts +775 -0
- package/dist/types/types/content.d.ts +138 -0
- package/dist/types/types/csat.d.ts +110 -0
- package/dist/types/types/events.d.ts +242 -0
- package/dist/types/types/extras.d.ts +353 -0
- package/dist/types/types/incoming-webhooks.d.ts +78 -0
- package/dist/types/types/index.d.ts +15 -0
- package/dist/types/types/liveflex.d.ts +578 -0
- package/dist/types/types/models.d.ts +1753 -0
- package/dist/types/types/options.d.ts +190 -0
- package/dist/types/types/shared-channels.d.ts +236 -0
- package/dist/types/types/workspace-gifs.d.ts +95 -0
- package/dist/types/types/workspace.d.ts +390 -0
- package/dist/types/ui/EmbedConfig.d.ts +38 -0
- package/dist/types/ui/EmbedUI.d.ts +44 -0
- package/dist/types/ui/Launcher.d.ts +122 -0
- package/dist/types/ui/brand.d.ts +27 -0
- package/dist/types/ui/embedMessages.d.ts +23 -0
- package/dist/types/ui/hours.d.ts +35 -0
- package/dist/types/ui/prechat.d.ts +35 -0
- package/dist/types/ui/widgetConfig.d.ts +4 -0
- package/dist/types/utils/crypto.d.ts +6 -0
- package/dist/types/utils/hmac.d.ts +40 -0
- package/dist/types/utils/permissions.d.ts +5 -0
- package/dist/types/utils/platform.d.ts +18 -0
- package/dist/types/utils/visitor.d.ts +2 -0
- package/dist/types/workspace-gifs.d.ts +95 -0
- package/dist/types/workspace-gifs.js +3 -0
- package/dist/types/workspace-gifs.js.map +1 -0
- package/dist/types/workspace.d.ts +390 -0
- package/dist/types/workspace.js +13 -0
- package/dist/types/workspace.js.map +1 -0
- package/dist/umd/livechatta.umd.js +7262 -0
- package/dist/umd/livechatta.umd.js.map +1 -0
- package/dist/umd/livechatta.umd.min.js +2 -0
- package/dist/umd/livechatta.umd.min.js.map +1 -0
- package/package.json +278 -4
|
@@ -0,0 +1,1446 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import SocketIO
|
|
3
|
+
|
|
4
|
+
/// APNs/FCM data of an incoming-call push; Decline without a socket = api().declineHopInvite(sessionId:).
|
|
5
|
+
public struct LiveChattaIncomingCall {
|
|
6
|
+
public static let pushType = "HOP_INVITE"
|
|
7
|
+
public static let category = "INCOMING_CALL"
|
|
8
|
+
public static let androidChannel = "livechatta_calls"
|
|
9
|
+
public static let ringSeconds = 30
|
|
10
|
+
public static let actionAnswer = "ANSWER"
|
|
11
|
+
public static let actionDecline = "DECLINE"
|
|
12
|
+
|
|
13
|
+
public let callId: String
|
|
14
|
+
public let sessionId: String
|
|
15
|
+
public let conversationId: String
|
|
16
|
+
public let invitedByName: String
|
|
17
|
+
public let participantCount: Int
|
|
18
|
+
public let linkCode: String
|
|
19
|
+
/// "audio" or "video" ("" on older servers).
|
|
20
|
+
public let media: String
|
|
21
|
+
/// Single-use, ~2 min, for `api().pushDeclineCall(token:)` from CallKit; "" for calls over 50 people.
|
|
22
|
+
public let declineToken: String
|
|
23
|
+
public let declineUrl: String
|
|
24
|
+
|
|
25
|
+
/// Parses the notification's userInfo (string values); nil when it is not a call push.
|
|
26
|
+
public init?(userInfo: [AnyHashable: Any]) {
|
|
27
|
+
func str(_ key: String) -> String { (userInfo[key] as? String) ?? "" }
|
|
28
|
+
guard str("type") == LiveChattaIncomingCall.pushType else { return nil }
|
|
29
|
+
let session = str("sessionId").isEmpty ? str("callId") : str("sessionId")
|
|
30
|
+
guard !session.isEmpty else { return nil }
|
|
31
|
+
sessionId = session
|
|
32
|
+
callId = str("callId").isEmpty ? session : str("callId")
|
|
33
|
+
conversationId = str("conversationId")
|
|
34
|
+
invitedByName = str("invitedByName")
|
|
35
|
+
participantCount = Int(str("participantCount")) ?? 0
|
|
36
|
+
linkCode = str("linkCode")
|
|
37
|
+
media = str("media")
|
|
38
|
+
declineToken = str("declineToken")
|
|
39
|
+
declineUrl = str("declineUrl")
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// HOP_INVITE_CANCEL push (also in the VoIP payload): end the CallKit ring; reason answered | declined | ended.
|
|
44
|
+
public struct LiveChattaCallCancel {
|
|
45
|
+
public static let pushType = "HOP_INVITE_CANCEL"
|
|
46
|
+
public let callId: String
|
|
47
|
+
public let sessionId: String
|
|
48
|
+
public let reason: String
|
|
49
|
+
|
|
50
|
+
public init?(userInfo: [AnyHashable: Any]) {
|
|
51
|
+
func str(_ key: String) -> String { (userInfo[key] as? String) ?? "" }
|
|
52
|
+
guard str("type") == LiveChattaCallCancel.pushType else { return nil }
|
|
53
|
+
let session = str("sessionId").isEmpty ? str("callId") : str("sessionId")
|
|
54
|
+
guard !session.isEmpty else { return nil }
|
|
55
|
+
sessionId = session
|
|
56
|
+
callId = str("callId").isEmpty ? session : str("callId")
|
|
57
|
+
reason = ["answered", "declined", "ended"].contains(str("reason")) ? str("reason") : "ended"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// iOS socket API mirroring the TypeScript SocketAPI: emitters ack via callback, listeners
|
|
62
|
+
// register for server events. Usage: README "iOS (Swift)".
|
|
63
|
+
public class LiveChattaSocketAPI {
|
|
64
|
+
|
|
65
|
+
private let socket: SocketIOClient
|
|
66
|
+
private weak var client: LiveChattaClient?
|
|
67
|
+
|
|
68
|
+
// Offline message queue
|
|
69
|
+
private struct QueuedEmit {
|
|
70
|
+
let event: String
|
|
71
|
+
let data: [String: Any]
|
|
72
|
+
let callback: (([String: Any]?) -> Void)?
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private var queue: [QueuedEmit] = []
|
|
76
|
+
|
|
77
|
+
/// Called with (event, error) when the server denies an emit; that emit's callback then gets nil.
|
|
78
|
+
public var onAckError: ((String, Any) -> Void)?
|
|
79
|
+
|
|
80
|
+
// MARK: - Event Constants
|
|
81
|
+
|
|
82
|
+
public struct Events {
|
|
83
|
+
public static let allConversations = "all-conversations"
|
|
84
|
+
public static let newConversation = "new-conversation"
|
|
85
|
+
public static let enterConversation = "enter-conversation"
|
|
86
|
+
public static let joinConversation = "join-conversation"
|
|
87
|
+
public static let editConversation = "edit-conversation"
|
|
88
|
+
public static let makeAdminConversation = "make-admin-conversation"
|
|
89
|
+
public static let toggleConversation = "toggle-conversation"
|
|
90
|
+
public static let statusChangeConversation = "status-change-conversation"
|
|
91
|
+
public static let memberStatusChangeConversation = "member-status-change-conversation"
|
|
92
|
+
public static let messageStatusChange = "message-status-change"
|
|
93
|
+
public static let messageReaction = "message-reaction"
|
|
94
|
+
public static let validatePassword = "validate-password"
|
|
95
|
+
public static let allMessages = "all-messages"
|
|
96
|
+
public static let newMessage = "new-message"
|
|
97
|
+
public static let newTyping = "new-typing"
|
|
98
|
+
public static let saveDraft = "save-draft"
|
|
99
|
+
public static let draftUpdated = "draft-updated"
|
|
100
|
+
public static let forgotPassword = "forgot-password"
|
|
101
|
+
public static let changePassword = "change-password"
|
|
102
|
+
public static let resetPassword = "reset-password"
|
|
103
|
+
public static let refreshToken = "refresh-token"
|
|
104
|
+
public static let revokeToken = "revoke-token"
|
|
105
|
+
public static let online = "online"
|
|
106
|
+
public static let offline = "offline"
|
|
107
|
+
public static let chatError = "chat-error"
|
|
108
|
+
public static let unreadCountUpdate = "unread-count-update"
|
|
109
|
+
public static let notification = "notification"
|
|
110
|
+
public static let editMessage = "edit-message"
|
|
111
|
+
public static let forwardMessage = "forward-message"
|
|
112
|
+
public static let forwardPost = "forward-post"
|
|
113
|
+
public static let messageFailed = "message-failed"
|
|
114
|
+
public static let messageRead = "message-read"
|
|
115
|
+
public static let searchMessages = "search-messages"
|
|
116
|
+
public static let scheduledMessage = "scheduled-message"
|
|
117
|
+
public static let searchChatUsers = "search-chat-users"
|
|
118
|
+
public static let threadMessages = "thread-messages"
|
|
119
|
+
public static let toggleBookmark = "toggle-bookmark"
|
|
120
|
+
public static let getBookmarks = "get-bookmarks"
|
|
121
|
+
public static let getAllBookmarks = "get-all-bookmarks"
|
|
122
|
+
public static let membershipRevoked = "membership-revoked"
|
|
123
|
+
public static let sharedChannelInvite = "shared-channel-invite"
|
|
124
|
+
public static let sharedChannelUpdated = "shared-channel-updated"
|
|
125
|
+
public static let votePoll = "vote-poll"
|
|
126
|
+
public static let pinConversation = "pin-conversation"
|
|
127
|
+
public static let conversationMembers = "conversation-members"
|
|
128
|
+
public static let allThreads = "all-threads"
|
|
129
|
+
public static let getPostMessages = "get-post-messages"
|
|
130
|
+
// Chat-link-wide @mention handle list (Redis-cached on the server).
|
|
131
|
+
public static let linkHandles = "link-handles"
|
|
132
|
+
// Real-time broadcasts when a chat user joins / updates in this link.
|
|
133
|
+
public static let linkUserJoined = "link-user-joined"
|
|
134
|
+
public static let linkUserUpdated = "link-user-updated"
|
|
135
|
+
|
|
136
|
+
// =============== HOP (voice / video / meetings) ===============
|
|
137
|
+
public static let hopStart = "hop-start"
|
|
138
|
+
public static let hopEnd = "hop-end"
|
|
139
|
+
public static let hopJoin = "hop-join"
|
|
140
|
+
public static let hopLeave = "hop-leave"
|
|
141
|
+
public static let hopConnectTransport = "hop-connect-transport"
|
|
142
|
+
public static let hopProduce = "hop-produce"
|
|
143
|
+
public static let hopConsume = "hop-consume"
|
|
144
|
+
public static let hopResumeConsumer = "hop-resume-consumer"
|
|
145
|
+
public static let hopMediaChange = "hop-media-change"
|
|
146
|
+
public static let hopScreenShareStart = "hop-screenshare-start"
|
|
147
|
+
public static let hopScreenShareStop = "hop-screenshare-stop"
|
|
148
|
+
public static let hopRecordingStart = "hop-recording-start"
|
|
149
|
+
public static let hopRecordingStop = "hop-recording-stop"
|
|
150
|
+
public static let hopInviteDecline = "hop-invite-decline"
|
|
151
|
+
public static let hopAdmit = "hop-admit"
|
|
152
|
+
public static let hopDeny = "hop-deny"
|
|
153
|
+
public static let hopIceRestart = "hop-ice-restart"
|
|
154
|
+
public static let hopRejoinRoom = "hop-rejoin-room"
|
|
155
|
+
public static let hopAdHocStart = "hop-ad-hoc-start"
|
|
156
|
+
public static let hopInviteRequest = "hop-invite-request"
|
|
157
|
+
public static let hopGetSession = "hop-get-session"
|
|
158
|
+
public static let hopListProducers = "hop-list-producers"
|
|
159
|
+
public static let hopListParticipants = "hop-list-participants"
|
|
160
|
+
public static let hopMuteParticipant = "hop-mute-participant"
|
|
161
|
+
public static let hopDropParticipant = "hop-drop-participant"
|
|
162
|
+
public static let hopPinForAll = "hop-pin-for-all"
|
|
163
|
+
public static let hopListActive = "hop-list-active"
|
|
164
|
+
public static let hopMeetingCreate = "hop-meeting-create"
|
|
165
|
+
public static let hopMeetingCancel = "hop-meeting-cancel"
|
|
166
|
+
public static let hopMeetingList = "hop-meeting-list"
|
|
167
|
+
// Broadcasts
|
|
168
|
+
public static let hopStarted = "hop-started"
|
|
169
|
+
public static let hopEnded = "hop-ended"
|
|
170
|
+
public static let hopParticipantJoined = "hop-participant-joined"
|
|
171
|
+
public static let hopParticipantLeft = "hop-participant-left"
|
|
172
|
+
public static let hopNewProducer = "hop-new-producer"
|
|
173
|
+
public static let hopProducerClosed = "hop-producer-closed"
|
|
174
|
+
public static let hopInvite = "hop-invite"
|
|
175
|
+
public static let hopLobbyWaiting = "hop-lobby-waiting"
|
|
176
|
+
public static let hopDenied = "hop-denied"
|
|
177
|
+
public static let hopRedirect = "hop-redirect"
|
|
178
|
+
public static let hopRecordingStarted = "hop-recording-started"
|
|
179
|
+
public static let hopRecordingStopped = "hop-recording-stopped"
|
|
180
|
+
public static let hopRecordingReady = "hop-recording-ready"
|
|
181
|
+
public static let hopRecordingAlreadyActive = "hop-recording-already-active"
|
|
182
|
+
public static let hopRecordingForbidden = "hop-recording-forbidden"
|
|
183
|
+
public static let hopInviteDeclined = "hop-invite-declined"
|
|
184
|
+
public static let hopScreenShareStarted = "hop-screenshare-started"
|
|
185
|
+
public static let hopMediaChanged = "hop-media-changed"
|
|
186
|
+
public static let hopTransportParams = "hop-transport-params"
|
|
187
|
+
public static let hopMeetingReminder = "hop-meeting-reminder"
|
|
188
|
+
public static let hopReaction = "hop-reaction"
|
|
189
|
+
public static let hopKeepWaiting = "hop-keep-waiting"
|
|
190
|
+
public static let hopVote = "hop-vote"
|
|
191
|
+
public static let hopVoteUpdated = "hop-vote-updated"
|
|
192
|
+
public static let hopRaiseHand = "hop-raise-hand"
|
|
193
|
+
public static let hopNewVoteRound = "hop-new-vote-round"
|
|
194
|
+
public static let hopVoteComplete = "hop-vote-complete"
|
|
195
|
+
public static let hopHostChanged = "hop-host-changed"
|
|
196
|
+
public static let hopMakeHost = "hop-make-host"
|
|
197
|
+
public static let hopParticipantMuted = "hop-participant-muted"
|
|
198
|
+
public static let hopPinnedForAll = "hop-pinned-for-all"
|
|
199
|
+
public static let hopParticipantDropped = "hop-participant-dropped"
|
|
200
|
+
public static let hopYouWereDropped = "hop-you-were-dropped"
|
|
201
|
+
public static let hopInviteAnswered = "hop-invite-answered"
|
|
202
|
+
public static let hopUnmuteRequested = "hop-unmute-requested"
|
|
203
|
+
public static let hopAdmitted = "hop-admitted"
|
|
204
|
+
|
|
205
|
+
public static let aiCreditsUpdated = "ai-credits-updated"
|
|
206
|
+
public static let aiCreditsExhausted = "ai-credits-exhausted"
|
|
207
|
+
|
|
208
|
+
// ========= WHITEBOARD =========
|
|
209
|
+
public static let whiteboardOpen = "whiteboard-open"
|
|
210
|
+
public static let whiteboardStroke = "whiteboard-stroke"
|
|
211
|
+
public static let whiteboardClear = "whiteboard-clear"
|
|
212
|
+
public static let whiteboardClose = "whiteboard-close"
|
|
213
|
+
public static let whiteboardSnapshot = "whiteboard-snapshot"
|
|
214
|
+
// Server → client broadcasts. The backend re-broadcasts on the SAME
|
|
215
|
+
// event names it receives (whiteboard-stroke/clear/close/snapshot), so
|
|
216
|
+
// these aliases resolve to the base names — NOT "*-received"/"*-ready".
|
|
217
|
+
public static let whiteboardStrokeReceived = "whiteboard-stroke"
|
|
218
|
+
public static let whiteboardCleared = "whiteboard-clear"
|
|
219
|
+
public static let whiteboardClosed = "whiteboard-close"
|
|
220
|
+
public static let whiteboardSnapshotReady = "whiteboard-snapshot"
|
|
221
|
+
|
|
222
|
+
// ========= AUTOMATION =========
|
|
223
|
+
public static let createAutomation = "create-automation"
|
|
224
|
+
public static let updateAutomation = "update-automation"
|
|
225
|
+
public static let deleteAutomation = "delete-automation"
|
|
226
|
+
public static let getAutomations = "get-automations"
|
|
227
|
+
|
|
228
|
+
// ========= WEBINAR =========
|
|
229
|
+
public static let startWebinar = "start-webinar"
|
|
230
|
+
public static let raiseHand = "raise-hand"
|
|
231
|
+
public static let lowerHand = "lower-hand"
|
|
232
|
+
public static let promoteAttendeeAudio = "promote-attendee-audio"
|
|
233
|
+
public static let webinarQaSubmit = "webinar-qa-submit"
|
|
234
|
+
public static let webinarQaAnswer = "webinar-qa-answer"
|
|
235
|
+
public static let webinarStarted = "webinar-started"
|
|
236
|
+
public static let webinarHandRaised = "webinar-hand-raised"
|
|
237
|
+
public static let webinarHandLowered = "webinar-hand-lowered"
|
|
238
|
+
public static let webinarAttendeePromoted = "webinar-attendee-promoted"
|
|
239
|
+
public static let webinarQaUpdated = "webinar-qa-updated"
|
|
240
|
+
|
|
241
|
+
// ========= CONVERSATION STATS =========
|
|
242
|
+
public static let getConversationStats = "get-conversation-stats"
|
|
243
|
+
// The backend replies to `get-conversation-stats` via the emit ack; it
|
|
244
|
+
// does not emit a separate "conversation-stats" broadcast. Alias kept
|
|
245
|
+
// pointing at the real event for any `onConversationStats` subscriber.
|
|
246
|
+
public static let conversationStats = "get-conversation-stats"
|
|
247
|
+
|
|
248
|
+
// ========= CHAT USER SETTINGS =========
|
|
249
|
+
public static let updateChatUserSettings = "update-chat-user-settings"
|
|
250
|
+
|
|
251
|
+
// ========= POSTS / STORIES =========
|
|
252
|
+
public static let createPost = "create-post"
|
|
253
|
+
public static let getPosts = "get-posts"
|
|
254
|
+
public static let getStories = "get-stories"
|
|
255
|
+
public static let viewPost = "view-post"
|
|
256
|
+
public static let reactToPost = "react-to-post"
|
|
257
|
+
public static let replyToPost = "reply-to-post"
|
|
258
|
+
public static let updatePost = "update-post"
|
|
259
|
+
public static let deletePost = "delete-post"
|
|
260
|
+
public static let newStory = "new-story"
|
|
261
|
+
|
|
262
|
+
// ========= TRANSLATION =========
|
|
263
|
+
public static let translateMessage = "translate-message"
|
|
264
|
+
public static let setLanguage = "set-language"
|
|
265
|
+
|
|
266
|
+
// ========= PRESENCE =========
|
|
267
|
+
public static let onlineUsers = "online-users"
|
|
268
|
+
public static let heartbeat = "heartbeat"
|
|
269
|
+
|
|
270
|
+
// ========= AUTH =========
|
|
271
|
+
public static let authError = "auth-error"
|
|
272
|
+
|
|
273
|
+
// ========= HOP COLLAB (co-host / poll / whiteboard) =========
|
|
274
|
+
public static let hopCoHostAssign = "hop-co-host-assign"
|
|
275
|
+
public static let hopCoHostAssigned = "hop-co-host-assigned"
|
|
276
|
+
public static let hopPollLaunch = "hop-poll-launch"
|
|
277
|
+
public static let hopPollLaunched = "hop-poll-launched"
|
|
278
|
+
public static let hopPollVote = "hop-poll-vote"
|
|
279
|
+
public static let hopPollVoteUpdated = "hop-poll-vote-updated"
|
|
280
|
+
public static let hopWhiteboardSync = "hop-whiteboard-sync"
|
|
281
|
+
public static let hopWhiteboardDelta = "hop-whiteboard-delta"
|
|
282
|
+
|
|
283
|
+
// Chat features (chatta planner/docs/chat-features-api.md)
|
|
284
|
+
public static let messageDelivered = "message-delivered"
|
|
285
|
+
public static let messageInfo = "message-info"
|
|
286
|
+
public static let muteConversation = "mute-conversation"
|
|
287
|
+
public static let conversationMuted = "conversation-muted"
|
|
288
|
+
public static let updateQuietHours = "update-quiet-hours"
|
|
289
|
+
public static let quietHoursUpdated = "quiet-hours-updated"
|
|
290
|
+
public static let setMessageReminder = "set-message-reminder"
|
|
291
|
+
public static let cancelMessageReminder = "cancel-message-reminder"
|
|
292
|
+
public static let messageRemindersChanged = "message-reminders-changed"
|
|
293
|
+
public static let messageReminderDue = "message-reminder-due"
|
|
294
|
+
public static let updateConversationPermissions = "update-conversation-permissions"
|
|
295
|
+
public static let conversationPermissionsUpdated = "conversation-permissions-updated"
|
|
296
|
+
public static let huddleStart = "huddle-start"
|
|
297
|
+
public static let huddleStatus = "huddle-status"
|
|
298
|
+
public static let huddleEnd = "huddle-end"
|
|
299
|
+
public static let huddleUpdated = "huddle-updated"
|
|
300
|
+
public static let setStatus = "set-status"
|
|
301
|
+
public static let statusUpdated = "status-updated"
|
|
302
|
+
public static let updateLiveLocation = "update-live-location"
|
|
303
|
+
public static let liveLocationUpdated = "live-location-updated"
|
|
304
|
+
public static let stopLiveLocation = "stop-live-location"
|
|
305
|
+
public static let liveLocationEnded = "live-location-ended"
|
|
306
|
+
public static let hopMeetingUpdated = "hop-meeting-updated"
|
|
307
|
+
public static let transcribeMessage = "transcribe-message"
|
|
308
|
+
public static let messageTranscriptUpdated = "message-transcript-updated"
|
|
309
|
+
public static let inboxUpdated = "inbox-updated"
|
|
310
|
+
|
|
311
|
+
// Hop collab: poll close, snapshot, live captions, recordings list
|
|
312
|
+
public static let hopPollClose = "hop-poll-close"
|
|
313
|
+
public static let hopCollabState = "hop-collab-state"
|
|
314
|
+
public static let hopCaptionsToggle = "hop-captions-toggle"
|
|
315
|
+
public static let hopCaption = "hop-caption"
|
|
316
|
+
public static let hopRecordingList = "hop-recording-list"
|
|
317
|
+
public static let linkSettingsUpdated = "link-settings-updated"
|
|
318
|
+
public static let callLogged = "call-logged"
|
|
319
|
+
public static let stickersMine = "stickers-mine"
|
|
320
|
+
public static let stickersSearch = "stickers-search"
|
|
321
|
+
public static let stickerUpload = "sticker-upload"
|
|
322
|
+
public static let stickerAdd = "sticker-add"
|
|
323
|
+
public static let stickerRemove = "sticker-remove"
|
|
324
|
+
public static let chattaMoneyCard = "chatta-money-card"
|
|
325
|
+
public static let chattaMoneyConfirm = "chatta-money-confirm"
|
|
326
|
+
public static let moneyCardGet = "money-card-get"
|
|
327
|
+
public static let moneyCardAction = "money-card-action"
|
|
328
|
+
public static let moneyCardUpdate = "money-card-update"
|
|
329
|
+
public static let webinarQaAnswerLive = "webinar-qa-answer-live"
|
|
330
|
+
public static let webinarQaVote = "webinar-qa-vote"
|
|
331
|
+
public static let webinarViewerCount = "webinar-viewer-count"
|
|
332
|
+
public static let hopCaptionsState = "hop-captions-state"
|
|
333
|
+
public static let hopCaptionText = "hop-caption-text"
|
|
334
|
+
|
|
335
|
+
// Support inbox (agent user: rooms) + chat core (chat-features-api.md §8b, §14)
|
|
336
|
+
public static let internalNote = "internal-note"
|
|
337
|
+
public static let internalNoteDeleted = "internal-note-deleted"
|
|
338
|
+
public static let conversationNotesUpdated = "conversation-notes-updated"
|
|
339
|
+
public static let csatUpdated = "csat-updated"
|
|
340
|
+
public static let conversationRead = "conversation-read"
|
|
341
|
+
public static let conversationUnread = "conversation-unread"
|
|
342
|
+
public static let unreadTotals = "unread-totals"
|
|
343
|
+
public static let deleteMessage = "delete-message"
|
|
344
|
+
public static let messageDeleted = "message-deleted"
|
|
345
|
+
public static let searchAll = "search-all"
|
|
346
|
+
public static let submitPreChat = "submit-pre-chat"
|
|
347
|
+
public static let preChatSubmitted = "pre-chat-submitted"
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/// Valid status values for changeMessageStatus().
|
|
351
|
+
public struct MessageChangeStatus {
|
|
352
|
+
public static let delete = "DELETE"
|
|
353
|
+
public static let pin = "PIN"
|
|
354
|
+
public static let unpin = "UNPIN"
|
|
355
|
+
public static let starred = "STARRED"
|
|
356
|
+
public static let unstarred = "UNSTARRED"
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/// Conversation roles — ADMIN and MODERATOR can delete any message.
|
|
360
|
+
public struct ConversationRole {
|
|
361
|
+
public static let superAdmin = "SUPER_ADMIN"
|
|
362
|
+
public static let admin = "ADMIN"
|
|
363
|
+
public static let moderator = "MODERATOR"
|
|
364
|
+
public static let member = "MEMBER"
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/// `linkAccess` on the unfiltered first getConversations() page; `.blocked` = show the blocked-member state.
|
|
368
|
+
public enum LinkAccess: String {
|
|
369
|
+
case ok
|
|
370
|
+
case blocked
|
|
371
|
+
/// Invite-only link and this member is not on the list: no link room; show the invite-only state.
|
|
372
|
+
case inviteOnly = "invite-only"
|
|
373
|
+
|
|
374
|
+
public static func from(_ result: [String: Any]?) -> LinkAccess? {
|
|
375
|
+
(result?["linkAccess"] as? String).flatMap(LinkAccess.init(rawValue:))
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/// Sidebar paging (chatta #427): `all-conversations` default and max are 40; badges read `unreadTotals`.
|
|
380
|
+
public enum Sidebar {
|
|
381
|
+
public static let pageSize = 40
|
|
382
|
+
public static let maxExcludeIds = 1000
|
|
383
|
+
|
|
384
|
+
/// `unreadTotals.total` from a first page or `unread-totals` ack; nil when the server sent none.
|
|
385
|
+
public static func unreadTotal(_ result: [String: Any]?) -> Int? {
|
|
386
|
+
((result?["unreadTotals"] as? [String: Any])?["total"] as? NSNumber)?.intValue
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
internal init(socket: SocketIOClient, client: LiveChattaClient) {
|
|
391
|
+
self.socket = socket
|
|
392
|
+
self.client = client
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// MARK: - Emitters
|
|
396
|
+
|
|
397
|
+
/// Fetch user's conversations; the unfiltered first page also carries `linkAccess` (see `LinkAccess`).
|
|
398
|
+
public func getConversations(_ query: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
399
|
+
emit(Events.allConversations, data: query, callback: callback)
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/// Start a new conversation; GROUP / CHANNEL may set mode (standard|broadcast|announcement|qa|voice|support) and category
|
|
403
|
+
public func startConversation(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
404
|
+
emit(Events.newConversation, data: data, callback: callback)
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/// Enter a conversation (join room, get presence)
|
|
408
|
+
public func enterConversation(_ conversationId: String, callback: (([String: Any]?) -> Void)? = nil) {
|
|
409
|
+
emit(Events.enterConversation, data: ["conversationId": conversationId], callback: callback)
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
/// Join an existing conversation with participants
|
|
413
|
+
public func joinConversation(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
414
|
+
emit(Events.joinConversation, data: data, callback: callback)
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/// Edit conversation details (name, caption, photo)
|
|
418
|
+
public func editConversation(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
419
|
+
emit(Events.editConversation, data: data, callback: callback)
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
/// Toggle pin on a conversation for the current member
|
|
423
|
+
public func pinConversation(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
424
|
+
emit(Events.pinConversation, data: data, callback: callback)
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/// Promote users to admin in a conversation
|
|
428
|
+
public func makeAdmin(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
429
|
+
emit(Events.makeAdminConversation, data: data, callback: callback)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/// Lock or unlock a conversation
|
|
433
|
+
public func toggleLock(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
434
|
+
emit(Events.toggleConversation, data: data, callback: callback)
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/// Change conversation status (ACTIVE, LEAVE, BLOCK)
|
|
438
|
+
public func changeConversationStatus(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
439
|
+
emit(Events.statusChangeConversation, data: data, callback: callback)
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/// Change a member's status in a conversation
|
|
443
|
+
public func changeMemberStatus(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
444
|
+
emit(Events.memberStatusChangeConversation, data: data, callback: callback)
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/// Fetch paginated messages with filters; compactReceipts "1" = only your own readBy / deliveredTo entry plus readCount / deliveredCount
|
|
448
|
+
public func getMessages(_ query: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
449
|
+
emit(Events.allMessages, data: query, callback: callback)
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/// Send a message; polls: messageKind "POLL", question, options, multiSelect?, anonymous? (counts only)
|
|
453
|
+
public func sendMessage(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
454
|
+
emit(Events.newMessage, data: data, callback: callback)
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/// Save a conversation draft; it syncs to this member's other devices
|
|
458
|
+
public func saveDraft(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
459
|
+
emit(Events.saveDraft, data: data, callback: callback)
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/// Set your custom status (/status, /away): { text?, emoji?, away? }; empty text and away false clears it. Ack: { userId?, statusText, statusEmoji, statusAway }
|
|
463
|
+
public func setChatStatus(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
464
|
+
emit(Events.setStatus, data: data, callback: callback)
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/// Move a live-location point you shared; it broadcasts to the conversation
|
|
468
|
+
public func updateLiveLocation(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
469
|
+
emit(Events.updateLiveLocation, data: data, callback: callback)
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/// End a live-location share early
|
|
473
|
+
public func stopLiveLocation(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
474
|
+
emit(Events.stopLiveLocation, data: data, callback: callback)
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/// Broadcast typing indicator
|
|
478
|
+
public func typing(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
479
|
+
emit(Events.newTyping, data: data, callback: callback)
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/// Change a message's status (e.g., DELETED)
|
|
483
|
+
public func changeMessageStatus(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
484
|
+
emit(Events.messageStatusChange, data: data, callback: callback)
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
/// React to a message with an emoji
|
|
488
|
+
public func reactToMessage(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
489
|
+
emit(Events.messageReaction, data: data, callback: callback)
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
/// Edit an existing message
|
|
493
|
+
/// data: { messageId, conversationId, senderId, message }. Past 24 h the ack error code is EDIT_WINDOW_CLOSED.
|
|
494
|
+
public func editMessage(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
495
|
+
emit(Events.editMessage, data: data, callback: callback)
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/// data: { messageId, fromConversationId, toConversationId, senderId }; one target per call
|
|
499
|
+
public func forwardMessage(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
500
|
+
emit(Events.forwardMessage, data: data, callback: callback)
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/// Forward a post to a conversation
|
|
504
|
+
public func forwardPost(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
505
|
+
emit(Events.forwardPost, data: data, callback: callback)
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/// Mark messages as read in a conversation
|
|
509
|
+
public func markMessagesRead(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
510
|
+
emit(Events.messageRead, data: data, callback: callback)
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/// Search messages in a conversation
|
|
514
|
+
public func searchMessages(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
515
|
+
emit(Events.searchMessages, data: data, callback: callback)
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/// Search chat users by name/handle
|
|
519
|
+
public func searchChatUsers(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
520
|
+
emit(Events.searchChatUsers, data: data, callback: callback)
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
/// Link-wide @mention handles (Redis-cached, safe to repeat) for a picker beyond the current
|
|
524
|
+
/// conversation; keep fresh via onLinkUserJoined / onLinkUserUpdated.
|
|
525
|
+
public func getLinkHandles(callback: (([String: Any]?) -> Void)? = nil) {
|
|
526
|
+
emit(Events.linkHandles, data: [:], callback: callback)
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/// Fetch members of a conversation.
|
|
530
|
+
public func getConversationMembers(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
531
|
+
emit(Events.conversationMembers, data: data, callback: callback)
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/// Fetch all parent thread messages (Pulse+ plan-gated, cursor-paginated).
|
|
535
|
+
public func getAllThreads(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
536
|
+
emit(Events.allThreads, data: data, callback: callback)
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
/// Fetch messages in a thread post.
|
|
540
|
+
public func getPostMessages(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
541
|
+
emit(Events.getPostMessages, data: data, callback: callback)
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/// Fetch thread replies for a parent message
|
|
545
|
+
public func getThreadMessages(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
546
|
+
emit(Events.threadMessages, data: data, callback: callback)
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
/// Toggle bookmark on a message
|
|
550
|
+
public func toggleBookmark(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
551
|
+
emit(Events.toggleBookmark, data: data, callback: callback)
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/// Get bookmarked messages in a conversation
|
|
555
|
+
public func getBookmarks(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
556
|
+
emit(Events.getBookmarks, data: data, callback: callback)
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
/// All bookmarked messages across conversations; data: { cursor?, limit? }
|
|
560
|
+
public func getAllBookmarks(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
561
|
+
emit(Events.getAllBookmarks, data: data, callback: callback)
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
/// Vote on a poll option
|
|
565
|
+
public func votePoll(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
566
|
+
emit(Events.votePoll, data: data, callback: callback)
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
/// Validate a user's password
|
|
570
|
+
public func validatePassword(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
571
|
+
emit(Events.validatePassword, data: data, callback: callback)
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/// Email a chat user a reset code; data: { identifier, chatLinkCode } (chatLinkCode required since 1.2.2 / chatta #413)
|
|
575
|
+
public func forgotPassword(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
576
|
+
emit(Events.forgotPassword, data: data, callback: callback)
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
/// data: { token, newPassword, confirmPassword } (8–200, must match): { status, message, audience, loginUrl, signedOut }
|
|
580
|
+
public func resetPassword(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
581
|
+
emit(Events.resetPassword, data: data, callback: callback)
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/// Change authenticated user's password
|
|
585
|
+
public func changePassword(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
586
|
+
emit(Events.changePassword, data: data, callback: callback)
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
/// Refresh authentication token
|
|
590
|
+
public func refreshToken(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
591
|
+
emit(Events.refreshToken, data: data, callback: callback)
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
/// Revoke authentication token
|
|
595
|
+
public func revokeToken(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
596
|
+
emit(Events.revokeToken, data: data, callback: callback)
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// MARK: - Listeners
|
|
600
|
+
|
|
601
|
+
/// Listen for new messages
|
|
602
|
+
@discardableResult
|
|
603
|
+
public func onMessage(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
604
|
+
listen(Events.newMessage, callback: callback)
|
|
605
|
+
return self
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/// Listen for new conversations
|
|
609
|
+
@discardableResult
|
|
610
|
+
public func onConversation(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
611
|
+
listen(Events.newConversation, callback: callback)
|
|
612
|
+
return self
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
/// Listen for conversation edits
|
|
616
|
+
@discardableResult
|
|
617
|
+
public func onEditConversation(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
618
|
+
listen(Events.editConversation, callback: callback)
|
|
619
|
+
return self
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
/// Listen for admin role changes. Payload: `{ conversation, memberId, member }`.
|
|
623
|
+
@discardableResult
|
|
624
|
+
public func onMakeAdmin(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
625
|
+
listen(Events.makeAdminConversation, callback: callback)
|
|
626
|
+
return self
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/// Convenience listener for lock/unlock. NOTE: the backend re-broadcasts a
|
|
630
|
+
/// toggle as an `edit-conversation` frame — prefer `onEditConversation`.
|
|
631
|
+
/// Kept for parity with the TS SDK.
|
|
632
|
+
@discardableResult
|
|
633
|
+
public func onToggleConversation(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
634
|
+
listen(Events.toggleConversation, callback: callback)
|
|
635
|
+
return self
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/// Convenience listener for status changes. NOTE: the backend re-broadcasts
|
|
639
|
+
/// a status change as an `edit-conversation` frame — prefer
|
|
640
|
+
/// `onEditConversation`. Kept for parity with the TS SDK.
|
|
641
|
+
@discardableResult
|
|
642
|
+
public func onStatusChangeConversation(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
643
|
+
listen(Events.statusChangeConversation, callback: callback)
|
|
644
|
+
return self
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
/// Listener for pin/unpin. NOTE: pinning is a per-member setting resolved
|
|
648
|
+
/// via the `pin-conversation` ack; the backend does not broadcast a separate
|
|
649
|
+
/// frame. Kept for parity with the TS SDK.
|
|
650
|
+
@discardableResult
|
|
651
|
+
public func onPinConversation(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
652
|
+
listen(Events.pinConversation, callback: callback)
|
|
653
|
+
return self
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
/// Listen for member status changes
|
|
657
|
+
@discardableResult
|
|
658
|
+
public func onMemberStatusChange(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
659
|
+
listen(Events.memberStatusChangeConversation, callback: callback)
|
|
660
|
+
return self
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/// Listen for message status changes
|
|
664
|
+
@discardableResult
|
|
665
|
+
public func onMessageStatusChange(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
666
|
+
listen(Events.messageStatusChange, callback: callback)
|
|
667
|
+
return self
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/// Listen for message reactions
|
|
671
|
+
@discardableResult
|
|
672
|
+
public func onMessageReaction(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
673
|
+
listen(Events.messageReaction, callback: callback)
|
|
674
|
+
return self
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
/// Listen for typing indicators
|
|
678
|
+
@discardableResult
|
|
679
|
+
public func onTyping(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
680
|
+
listen(Events.newTyping, callback: callback)
|
|
681
|
+
return self
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
/// Listen for a draft changed on another of this member's devices
|
|
685
|
+
@discardableResult
|
|
686
|
+
public func onDraftUpdated(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
687
|
+
listen(Events.draftUpdated, callback: callback)
|
|
688
|
+
return self
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/// Listen for users coming online
|
|
692
|
+
@discardableResult
|
|
693
|
+
public func onOnline(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
694
|
+
listen(Events.online, callback: callback)
|
|
695
|
+
return self
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
/// Listen for users going offline
|
|
699
|
+
@discardableResult
|
|
700
|
+
public func onOffline(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
701
|
+
listen(Events.offline, callback: callback)
|
|
702
|
+
return self
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/// Listen for users joining a conversation
|
|
706
|
+
@discardableResult
|
|
707
|
+
public func onJoinConversation(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
708
|
+
listen(Events.joinConversation, callback: callback)
|
|
709
|
+
return self
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/// Listen for unread count updates
|
|
713
|
+
@discardableResult
|
|
714
|
+
public func onUnreadCountUpdate(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
715
|
+
listen(Events.unreadCountUpdate, callback: callback)
|
|
716
|
+
return self
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
/// Membership revoked (kick/ban/leave): { conversationId, memberId, status }
|
|
720
|
+
@discardableResult
|
|
721
|
+
public func onMembershipRevoked(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
722
|
+
listen(Events.membershipRevoked, callback: callback)
|
|
723
|
+
return self
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
/// Another workspace invited yours to a channel (owner and admins only): { sharedChannelId, conversationId, status, side, hostName, partnerName, channelName }
|
|
727
|
+
@discardableResult
|
|
728
|
+
public func onSharedChannelInvite(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
729
|
+
listen(Events.sharedChannelInvite, callback: callback)
|
|
730
|
+
return self
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
/// A share changed (owner and admins of both sides: the invite fields plus archiveConversationId?) or a badge changed (channel members: { conversationId, sharedWith: [{ name, side, ended? }] })
|
|
734
|
+
@discardableResult
|
|
735
|
+
public func onSharedChannelUpdated(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
736
|
+
listen(Events.sharedChannelUpdated, callback: callback)
|
|
737
|
+
return self
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
/// Listen for notifications
|
|
741
|
+
@discardableResult
|
|
742
|
+
public func onNotification(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
743
|
+
listen(Events.notification, callback: callback)
|
|
744
|
+
return self
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
/// Listen for edited messages
|
|
748
|
+
@discardableResult
|
|
749
|
+
public func onEditMessage(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
750
|
+
listen(Events.editMessage, callback: callback)
|
|
751
|
+
return self
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/// Listen for forwarded messages
|
|
755
|
+
@discardableResult
|
|
756
|
+
public func onForwardMessage(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
757
|
+
listen(Events.forwardMessage, callback: callback)
|
|
758
|
+
return self
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/// Listen for message read receipts
|
|
762
|
+
@discardableResult
|
|
763
|
+
public func onMessageRead(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
764
|
+
listen(Events.messageRead, callback: callback)
|
|
765
|
+
return self
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/// Listen for scheduled messages
|
|
769
|
+
@discardableResult
|
|
770
|
+
public func onScheduledMessage(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
771
|
+
listen(Events.scheduledMessage, callback: callback)
|
|
772
|
+
return self
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/// Listen for message delivery failures
|
|
776
|
+
@discardableResult
|
|
777
|
+
public func onMessageFailed(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
778
|
+
listen(Events.messageFailed, callback: callback)
|
|
779
|
+
return self
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
/// Listen for poll vote updates
|
|
783
|
+
@discardableResult
|
|
784
|
+
public func onVotePoll(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
785
|
+
listen(Events.votePoll, callback: callback)
|
|
786
|
+
return self
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
/// Listen for new chat users joining the active chat link.
|
|
790
|
+
@discardableResult
|
|
791
|
+
public func onLinkUserJoined(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
792
|
+
listen(Events.linkUserJoined, callback: callback)
|
|
793
|
+
return self
|
|
794
|
+
}
|
|
795
|
+
|
|
796
|
+
/// Listen for handle/displayName/photo updates from chat link members.
|
|
797
|
+
@discardableResult
|
|
798
|
+
public func onLinkUserUpdated(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
799
|
+
listen(Events.linkUserUpdated, callback: callback)
|
|
800
|
+
return self
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
// MARK: - HOP (voice / video / meetings)
|
|
804
|
+
|
|
805
|
+
public func startHop(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
806
|
+
emit(Events.hopStart, data: data, callback: callback)
|
|
807
|
+
}
|
|
808
|
+
public func startHopAdHoc(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
809
|
+
emit(Events.hopAdHocStart, data: data, callback: callback)
|
|
810
|
+
}
|
|
811
|
+
/// Join a live Hop: router RTP caps + transport params; canProduce false = webinar attendee (consume only).
|
|
812
|
+
public func joinHop(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
813
|
+
emit(Events.hopJoin, data: data, callback: callback)
|
|
814
|
+
}
|
|
815
|
+
public func leaveHop(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
816
|
+
emit(Events.hopLeave, data: data, callback: callback)
|
|
817
|
+
}
|
|
818
|
+
public func endHop(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
819
|
+
emit(Events.hopEnd, data: data, callback: callback)
|
|
820
|
+
}
|
|
821
|
+
public func inviteToHop(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
822
|
+
emit(Events.hopInviteRequest, data: data, callback: callback)
|
|
823
|
+
}
|
|
824
|
+
public func getHopSession(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
825
|
+
emit(Events.hopGetSession, data: data, callback: callback)
|
|
826
|
+
}
|
|
827
|
+
public func hopConnectTransport(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
828
|
+
emit(Events.hopConnectTransport, data: data, callback: callback)
|
|
829
|
+
}
|
|
830
|
+
public func hopProduce(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
831
|
+
emit(Events.hopProduce, data: data, callback: callback)
|
|
832
|
+
}
|
|
833
|
+
public func hopConsume(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
834
|
+
emit(Events.hopConsume, data: data, callback: callback)
|
|
835
|
+
}
|
|
836
|
+
public func hopResumeConsumer(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
837
|
+
emit(Events.hopResumeConsumer, data: data, callback: callback)
|
|
838
|
+
}
|
|
839
|
+
public func hopStartRecording(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
840
|
+
emit(Events.hopRecordingStart, data: data, callback: callback)
|
|
841
|
+
}
|
|
842
|
+
public func hopStopRecording(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
843
|
+
emit(Events.hopRecordingStop, data: data, callback: callback)
|
|
844
|
+
}
|
|
845
|
+
/// data: { title, startAt, endAt, participantIds (may be empty), locationConversationId?, guestEmails? (≤20), … }; ack adds locationConversationId, guestsInvited
|
|
846
|
+
public func scheduleHopMeeting(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
847
|
+
emit(Events.hopMeetingCreate, data: data, callback: callback)
|
|
848
|
+
}
|
|
849
|
+
public func cancelHopMeeting(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
850
|
+
emit(Events.hopMeetingCancel, data: data, callback: callback)
|
|
851
|
+
}
|
|
852
|
+
public func listHopMeetings(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
853
|
+
emit(Events.hopMeetingList, data: data, callback: callback)
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
public func listHopProducers(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
857
|
+
emit(Events.hopListProducers, data: data, callback: callback)
|
|
858
|
+
}
|
|
859
|
+
public func listHopParticipants(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
860
|
+
emit(Events.hopListParticipants, data: data, callback: callback)
|
|
861
|
+
}
|
|
862
|
+
public func muteHopParticipant(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
863
|
+
emit(Events.hopMuteParticipant, data: data, callback: callback)
|
|
864
|
+
}
|
|
865
|
+
public func dropHopParticipant(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
866
|
+
emit(Events.hopDropParticipant, data: data, callback: callback)
|
|
867
|
+
}
|
|
868
|
+
/// Host / co-host only; data: { sessionId, userId? } (no userId clears). Ack: { pinned }
|
|
869
|
+
public func hopPinForAll(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
870
|
+
emit(Events.hopPinForAll, data: data, callback: callback)
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
public func listActiveHops(callback: (([String: Any]?) -> Void)? = nil) {
|
|
874
|
+
emit(Events.hopListActive, data: [:], callback: callback)
|
|
875
|
+
}
|
|
876
|
+
public func sendHopReaction(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
877
|
+
emit(Events.hopReaction, data: data, callback: callback)
|
|
878
|
+
}
|
|
879
|
+
public func keepHopWaiting(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
880
|
+
emit(Events.hopKeepWaiting, data: data, callback: callback)
|
|
881
|
+
}
|
|
882
|
+
public func sendHopVote(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
883
|
+
emit(Events.hopVote, data: data, callback: callback)
|
|
884
|
+
}
|
|
885
|
+
public func raiseHand(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
886
|
+
emit(Events.hopRaiseHand, data: data, callback: callback)
|
|
887
|
+
}
|
|
888
|
+
public func startNewVoteRound(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
889
|
+
emit(Events.hopNewVoteRound, data: data, callback: callback)
|
|
890
|
+
}
|
|
891
|
+
public func makeHost(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
892
|
+
emit(Events.hopMakeHost, data: data, callback: callback)
|
|
893
|
+
}
|
|
894
|
+
public func stopHopScreenShare(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
895
|
+
emit(Events.hopScreenShareStop, data: data, callback: callback)
|
|
896
|
+
}
|
|
897
|
+
public func rejoinHop(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
898
|
+
emit(Events.hopRejoinRoom, data: data, callback: callback)
|
|
899
|
+
}
|
|
900
|
+
public func restartHopIce(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
901
|
+
emit(Events.hopIceRestart, data: data, callback: callback)
|
|
902
|
+
}
|
|
903
|
+
public func hopAdmit(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
904
|
+
emit(Events.hopAdmit, data: data, callback: callback)
|
|
905
|
+
}
|
|
906
|
+
/// Deny a user waiting in the Hop lobby. Host/co-host only; `block` also stops them asking again. Ack: `{ ok: true }`.
|
|
907
|
+
public func hopDeny(_ sessionId: String, userId: String, block: Bool = false, callback: (([String: Any]?) -> Void)? = nil) {
|
|
908
|
+
var data: [String: Any] = ["sessionId": sessionId, "userId": userId]
|
|
909
|
+
if block { data["block"] = true }
|
|
910
|
+
emit(Events.hopDeny, data: data, callback: callback)
|
|
911
|
+
}
|
|
912
|
+
/// Decline a Hop invite. Payload: `{ sessionId }`. Ack: `{ ok: true }`.
|
|
913
|
+
public func hopInviteDecline(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
914
|
+
emit(Events.hopInviteDecline, data: data, callback: callback)
|
|
915
|
+
}
|
|
916
|
+
/// Update local media state (video/audio). Payload: `{ sessionId, videoEnabled?, audioEnabled? }`. Ack: `{ ok: true }`.
|
|
917
|
+
public func hopMediaChange(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
918
|
+
emit(Events.hopMediaChange, data: data, callback: callback)
|
|
919
|
+
}
|
|
920
|
+
/// Start screensharing. Payload: `{ sessionId, producerId? }`. Ack: `{ ok: true }`.
|
|
921
|
+
public func startHopScreenShare(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
922
|
+
emit(Events.hopScreenShareStart, data: data, callback: callback)
|
|
923
|
+
}
|
|
924
|
+
/// Alias for `startHopScreenShare` — mirrors the TS SDK surface.
|
|
925
|
+
public func hopScreenshareStart(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
926
|
+
emit(Events.hopScreenShareStart, data: data, callback: callback)
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
@discardableResult
|
|
930
|
+
public func onHopAdmitted(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
931
|
+
listen(Events.hopAdmitted, callback: cb); return self
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
// Hop listeners
|
|
935
|
+
@discardableResult
|
|
936
|
+
public func onHopStarted(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopStarted, callback: cb); return self }
|
|
937
|
+
@discardableResult
|
|
938
|
+
public func onHopEnded(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopEnded, callback: cb); return self }
|
|
939
|
+
@discardableResult
|
|
940
|
+
public func onHopParticipantJoined(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopParticipantJoined, callback: cb); return self }
|
|
941
|
+
@discardableResult
|
|
942
|
+
public func onHopParticipantLeft(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopParticipantLeft, callback: cb); return self }
|
|
943
|
+
@discardableResult
|
|
944
|
+
public func onHopNewProducer(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopNewProducer, callback: cb); return self }
|
|
945
|
+
@discardableResult
|
|
946
|
+
public func onHopProducerClosed(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopProducerClosed, callback: cb); return self }
|
|
947
|
+
@discardableResult
|
|
948
|
+
public func onHopInvite(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopInvite, callback: cb); return self }
|
|
949
|
+
@discardableResult
|
|
950
|
+
public func onHopRecordingStarted(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopRecordingStarted, callback: cb); return self }
|
|
951
|
+
@discardableResult
|
|
952
|
+
public func onHopRecordingStopped(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopRecordingStopped, callback: cb); return self }
|
|
953
|
+
@discardableResult
|
|
954
|
+
public func onHopRecordingReady(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopRecordingReady, callback: cb); return self }
|
|
955
|
+
@discardableResult
|
|
956
|
+
public func onHopMeetingReminder(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopMeetingReminder, callback: cb); return self }
|
|
957
|
+
@discardableResult
|
|
958
|
+
public func onHopRedirect(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopRedirect, callback: cb); return self }
|
|
959
|
+
@discardableResult
|
|
960
|
+
public func onHopReaction(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopReaction, callback: cb); return self }
|
|
961
|
+
@discardableResult
|
|
962
|
+
public func onHopVoteUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopVoteUpdated, callback: cb); return self }
|
|
963
|
+
@discardableResult
|
|
964
|
+
public func onHopRaiseHand(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopRaiseHand, callback: cb); return self }
|
|
965
|
+
@discardableResult
|
|
966
|
+
public func onHopVoteComplete(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopVoteComplete, callback: cb); return self }
|
|
967
|
+
@discardableResult
|
|
968
|
+
public func onHopNewVoteRound(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopNewVoteRound, callback: cb); return self }
|
|
969
|
+
@discardableResult
|
|
970
|
+
public func onHopHostChanged(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopHostChanged, callback: cb); return self }
|
|
971
|
+
/// Hosts: { sessionId, userId, displayName } is waiting in the lobby
|
|
972
|
+
@discardableResult
|
|
973
|
+
public func onHopLobbyWaiting(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopLobbyWaiting, callback: cb); return self }
|
|
974
|
+
@discardableResult
|
|
975
|
+
public func onHopDenied(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopDenied, callback: cb); return self }
|
|
976
|
+
@discardableResult
|
|
977
|
+
public func onHopRecordingAlreadyActive(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopRecordingAlreadyActive, callback: cb); return self }
|
|
978
|
+
@discardableResult
|
|
979
|
+
public func onHopParticipantMuted(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopParticipantMuted, callback: cb); return self }
|
|
980
|
+
/// { sessionId, userId (NSNull = unpin), by }: pin that tile for everyone.
|
|
981
|
+
@discardableResult public func onHopPinnedForAll(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopPinnedForAll, callback: cb); return self }
|
|
982
|
+
@discardableResult
|
|
983
|
+
public func onHopParticipantDropped(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopParticipantDropped, callback: cb); return self }
|
|
984
|
+
/// { sessionId, reason? }; reason "moved" = you joined this call from another device
|
|
985
|
+
@discardableResult
|
|
986
|
+
public func onHopYouWereDropped(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopYouWereDropped, callback: cb); return self }
|
|
987
|
+
/// { sessionId, conversationId }: you answered on another device, stop ringing here
|
|
988
|
+
@discardableResult public func onHopInviteAnswered(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopInviteAnswered, callback: cb); return self }
|
|
989
|
+
/// { sessionId, by }: a host asked you to unmute (the mic stays off until you turn it on)
|
|
990
|
+
@discardableResult public func onHopUnmuteRequested(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopUnmuteRequested, callback: cb); return self }
|
|
991
|
+
/// Fires when a participant declines a Hop invite. Payload: `{ sessionId, declinedBy }`.
|
|
992
|
+
@discardableResult
|
|
993
|
+
public func onHopInviteDeclined(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopInviteDeclined, callback: cb); return self }
|
|
994
|
+
/// Fires when a participant toggles video/audio. Payload: `{ sessionId, userId, videoEnabled?, audioEnabled? }`.
|
|
995
|
+
@discardableResult
|
|
996
|
+
public func onHopMediaChanged(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopMediaChanged, callback: cb); return self }
|
|
997
|
+
/// Fires when a participant starts screensharing. Payload: `{ sessionId, producerId, userId }`.
|
|
998
|
+
@discardableResult
|
|
999
|
+
public func onHopScreenshareStarted(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopScreenShareStarted, callback: cb); return self }
|
|
1000
|
+
/// Fires when a transport is confirmed connected. Payload: `{ sessionId, transportId, status }`.
|
|
1001
|
+
@discardableResult
|
|
1002
|
+
public func onHopTransportParams(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopTransportParams, callback: cb); return self }
|
|
1003
|
+
/// Fires when recording is forbidden by plan/permission. Payload: `{ sessionId, reason }`.
|
|
1004
|
+
@discardableResult
|
|
1005
|
+
public func onHopRecordingForbidden(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopRecordingForbidden, callback: cb); return self }
|
|
1006
|
+
/// Fires when a vote fly-animation is broadcast. Payload: `{ sessionId, userId, direction, conversationId }`.
|
|
1007
|
+
@discardableResult
|
|
1008
|
+
public func onHopVote(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopVote, callback: cb); return self }
|
|
1009
|
+
|
|
1010
|
+
// MARK: - Whiteboard
|
|
1011
|
+
|
|
1012
|
+
/// Open (create) a whiteboard. Backend `OpenWhiteboardDto` requires
|
|
1013
|
+
/// `conversationId` + `chatLinkId`; pass `chatLinkId` when known. The ack
|
|
1014
|
+
/// returns the created board — retain its id for later calls.
|
|
1015
|
+
@discardableResult public func openWhiteboard(_ conversationId: String, chatLinkId: String? = nil) -> LiveChattaSocketAPI {
|
|
1016
|
+
var payload: [String: Any] = ["conversationId": conversationId]
|
|
1017
|
+
if let chatLinkId = chatLinkId { payload["chatLinkId"] = chatLinkId }
|
|
1018
|
+
emit(Events.whiteboardOpen, data: payload, callback: nil); return self
|
|
1019
|
+
}
|
|
1020
|
+
@discardableResult public func sendWhiteboardStroke(_ data: [String: Any]) -> LiveChattaSocketAPI { emit(Events.whiteboardStroke, data: data, callback: nil); return self }
|
|
1021
|
+
/// Clear a whiteboard. `whiteboardId` optional — forwarded when the caller
|
|
1022
|
+
/// has it, otherwise the backend derives it from the conversation board.
|
|
1023
|
+
@discardableResult public func clearWhiteboard(_ conversationId: String, whiteboardId: String? = nil) -> LiveChattaSocketAPI {
|
|
1024
|
+
var payload: [String: Any] = ["conversationId": conversationId]
|
|
1025
|
+
if let whiteboardId = whiteboardId { payload["whiteboardId"] = whiteboardId }
|
|
1026
|
+
emit(Events.whiteboardClear, data: payload, callback: nil); return self
|
|
1027
|
+
}
|
|
1028
|
+
/// Close a whiteboard. `whiteboardId` optional — see `clearWhiteboard`.
|
|
1029
|
+
@discardableResult public func closeWhiteboard(_ conversationId: String, whiteboardId: String? = nil) -> LiveChattaSocketAPI {
|
|
1030
|
+
var payload: [String: Any] = ["conversationId": conversationId]
|
|
1031
|
+
if let whiteboardId = whiteboardId { payload["whiteboardId"] = whiteboardId }
|
|
1032
|
+
emit(Events.whiteboardClose, data: payload, callback: nil); return self
|
|
1033
|
+
}
|
|
1034
|
+
@discardableResult public func snapshotWhiteboard(_ data: [String: Any]) -> LiveChattaSocketAPI { emit(Events.whiteboardSnapshot, data: data, callback: nil); return self }
|
|
1035
|
+
@discardableResult public func onWhiteboardStrokeReceived(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.whiteboardStrokeReceived, callback: cb); return self }
|
|
1036
|
+
@discardableResult public func onWhiteboardCleared(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.whiteboardCleared, callback: cb); return self }
|
|
1037
|
+
@discardableResult public func onWhiteboardClosed(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.whiteboardClosed, callback: cb); return self }
|
|
1038
|
+
@discardableResult public func onWhiteboardSnapshotReady(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.whiteboardSnapshotReady, callback: cb); return self }
|
|
1039
|
+
|
|
1040
|
+
// MARK: - Automation
|
|
1041
|
+
|
|
1042
|
+
/// data: { chatLinkId, name, trigger, triggerConfig?: { keywords? }, action, actionConfig?, extraActions? (≤3 { action, actionConfig }) }; actions incl. REPLY_CANNED (cannedId), ASSIGN_TEAM (assigneeId)
|
|
1043
|
+
@discardableResult public func createAutomation(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.createAutomation, data: data, callback: callback); return self }
|
|
1044
|
+
/// data: { automationId, …, extraActions? } — extraActions replaces the extra steps ([] clears)
|
|
1045
|
+
@discardableResult public func updateAutomation(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.updateAutomation, data: data, callback: callback); return self }
|
|
1046
|
+
@discardableResult public func deleteAutomation(_ automationId: String, callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.deleteAutomation, data: ["automationId": automationId], callback: callback); return self }
|
|
1047
|
+
/// List automations for a chat link. The backend `GetAutomationsDto`
|
|
1048
|
+
/// requires `chatLinkId` — omitting it returns a 400. Acks with `{ automations }`.
|
|
1049
|
+
@discardableResult public func getAutomations(_ chatLinkId: String, callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.getAutomations, data: ["chatLinkId": chatLinkId], callback: callback); return self }
|
|
1050
|
+
|
|
1051
|
+
// MARK: - Webinar
|
|
1052
|
+
|
|
1053
|
+
@discardableResult public func startWebinar(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.startWebinar, data: data, callback: callback); return self }
|
|
1054
|
+
@discardableResult public func raiseHandWebinar(_ conversationId: String) -> LiveChattaSocketAPI { emit(Events.raiseHand, data: ["conversationId": conversationId], callback: nil); return self }
|
|
1055
|
+
@discardableResult public func lowerHand(_ conversationId: String) -> LiveChattaSocketAPI { emit(Events.lowerHand, data: ["conversationId": conversationId], callback: nil); return self }
|
|
1056
|
+
@discardableResult public func promoteAttendeeAudio(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.promoteAttendeeAudio, data: data, callback: callback); return self }
|
|
1057
|
+
@discardableResult public func submitWebinarQa(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.webinarQaSubmit, data: data, callback: callback); return self }
|
|
1058
|
+
@discardableResult public func answerWebinarQa(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.webinarQaAnswer, data: data, callback: callback); return self }
|
|
1059
|
+
@discardableResult public func onCallLogged(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.callLogged, callback: cb); return self }
|
|
1060
|
+
@discardableResult public func onChattaMoneyCard(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.chattaMoneyCard, callback: cb); return self }
|
|
1061
|
+
/// 1.7.0: a shared money card changed (paid, declined, cancelled, expired, contribution, payout)
|
|
1062
|
+
@discardableResult public func onMoneyCardUpdate(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.moneyCardUpdate, callback: cb); return self }
|
|
1063
|
+
@discardableResult public func onLinkSettingsUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.linkSettingsUpdated, callback: cb); return self }
|
|
1064
|
+
@discardableResult public func onWebinarViewerCount(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.webinarViewerCount, callback: cb); return self }
|
|
1065
|
+
@discardableResult public func onWebinarStarted(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.webinarStarted, callback: cb); return self }
|
|
1066
|
+
@discardableResult public func onWebinarRaisedHand(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.webinarHandRaised, callback: cb); return self }
|
|
1067
|
+
@discardableResult public func onWebinarHandLowered(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.webinarHandLowered, callback: cb); return self }
|
|
1068
|
+
@discardableResult public func onWebinarAttendeePromoted(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.webinarAttendeePromoted, callback: cb); return self }
|
|
1069
|
+
@discardableResult public func onWebinarQaUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.webinarQaUpdated, callback: cb); return self }
|
|
1070
|
+
|
|
1071
|
+
// MARK: - Conversation Stats
|
|
1072
|
+
|
|
1073
|
+
@discardableResult public func getConversationStats(_ conversationId: String, callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.getConversationStats, data: ["conversationId": conversationId], callback: callback); return self }
|
|
1074
|
+
@discardableResult public func onConversationStats(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.conversationStats, callback: cb); return self }
|
|
1075
|
+
@discardableResult public func onAiCreditsUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.aiCreditsUpdated, callback: cb); return self }
|
|
1076
|
+
@discardableResult public func onAiCreditsExhausted(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.aiCreditsExhausted, callback: cb); return self }
|
|
1077
|
+
|
|
1078
|
+
// MARK: - Chat User Settings
|
|
1079
|
+
|
|
1080
|
+
@discardableResult public func updateChatUserSettings(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.updateChatUserSettings, data: data, callback: callback); return self }
|
|
1081
|
+
|
|
1082
|
+
// MARK: - Posts / Stories
|
|
1083
|
+
|
|
1084
|
+
/// Create a post or story; allowReplies? (default true), background? (STORY: ink|brand|lagoon|sun)
|
|
1085
|
+
@discardableResult public func createPost(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.createPost, data: data, callback: callback); return self }
|
|
1086
|
+
/// Fetch posts (cursor-paginated). Acks with `{ results, nextCursor, hasMore }`.
|
|
1087
|
+
@discardableResult public func getPosts(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.getPosts, data: data, callback: callback); return self }
|
|
1088
|
+
/// Fetch active stories.
|
|
1089
|
+
@discardableResult public func getStories(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.getStories, data: data, callback: callback); return self }
|
|
1090
|
+
/// Mark a post/story as viewed.
|
|
1091
|
+
@discardableResult public func viewPost(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.viewPost, data: data, callback: callback); return self }
|
|
1092
|
+
/// React to a post with an emoji.
|
|
1093
|
+
@discardableResult public func reactToPost(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.reactToPost, data: data, callback: callback); return self }
|
|
1094
|
+
/// Reply to a post.
|
|
1095
|
+
@discardableResult public func replyToPost(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.replyToPost, data: data, callback: callback); return self }
|
|
1096
|
+
/// Update a post's content/caption/attachments.
|
|
1097
|
+
@discardableResult public func updatePost(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.updatePost, data: data, callback: callback); return self }
|
|
1098
|
+
/// Delete a post.
|
|
1099
|
+
@discardableResult public func deletePost(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.deletePost, data: data, callback: callback); return self }
|
|
1100
|
+
|
|
1101
|
+
@discardableResult public func onCreatePost(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.createPost, callback: cb); return self }
|
|
1102
|
+
@discardableResult public func onNewStory(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.newStory, callback: cb); return self }
|
|
1103
|
+
@discardableResult public func onUpdatePost(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.updatePost, callback: cb); return self }
|
|
1104
|
+
@discardableResult public func onDeletePost(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.deletePost, callback: cb); return self }
|
|
1105
|
+
@discardableResult public func onReactToPost(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.reactToPost, callback: cb); return self }
|
|
1106
|
+
@discardableResult public func onReplyToPost(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.replyToPost, callback: cb); return self }
|
|
1107
|
+
|
|
1108
|
+
// MARK: - Translation
|
|
1109
|
+
|
|
1110
|
+
/// Translate a message. Ack: `{ messageId, targetLanguage, translation, cached }` or `{ error }`.
|
|
1111
|
+
@discardableResult public func translateMessage(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.translateMessage, data: data, callback: callback); return self }
|
|
1112
|
+
/// Set the caller's preferred language. Ack: `{ success, language }`.
|
|
1113
|
+
@discardableResult public func setLanguage(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.setLanguage, data: data, callback: callback); return self }
|
|
1114
|
+
@discardableResult public func onTranslateMessage(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.translateMessage, callback: cb); return self }
|
|
1115
|
+
|
|
1116
|
+
// MARK: - Presence
|
|
1117
|
+
|
|
1118
|
+
/// Resolve which of `memberIds` are currently online. Ack: `{ onlineUserIds }`.
|
|
1119
|
+
@discardableResult public func getOnlineUsers(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) -> LiveChattaSocketAPI { emit(Events.onlineUsers, data: data, callback: callback); return self }
|
|
1120
|
+
/// Send a presence heartbeat (recommended every 30s). `visible: false` while the chat is hidden, so a push still goes out.
|
|
1121
|
+
@discardableResult public func heartbeat(visible: Bool? = nil) -> LiveChattaSocketAPI {
|
|
1122
|
+
var data: [String: Any] = [:]
|
|
1123
|
+
if let visible = visible { data["visible"] = visible }
|
|
1124
|
+
emit(Events.heartbeat, data: data, callback: nil)
|
|
1125
|
+
return self
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
// MARK: - Hop collaboration (co-host / poll / whiteboard)
|
|
1129
|
+
|
|
1130
|
+
/// Promote a participant to co-host. Host/co-host only.
|
|
1131
|
+
@discardableResult public func hopCoHostAssign(_ data: [String: Any]) -> LiveChattaSocketAPI { emit(Events.hopCoHostAssign, data: data, callback: nil); return self }
|
|
1132
|
+
@discardableResult public func onHopCoHostAssigned(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopCoHostAssigned, callback: cb); return self }
|
|
1133
|
+
/// Launch a poll visible to all session participants.
|
|
1134
|
+
@discardableResult public func hopPollLaunch(_ data: [String: Any]) -> LiveChattaSocketAPI { emit(Events.hopPollLaunch, data: data, callback: nil); return self }
|
|
1135
|
+
@discardableResult public func onHopPollLaunched(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopPollLaunched, callback: cb); return self }
|
|
1136
|
+
/// Cast a vote in a running hop poll.
|
|
1137
|
+
@discardableResult public func hopPollVote(_ data: [String: Any]) -> LiveChattaSocketAPI { emit(Events.hopPollVote, data: data, callback: nil); return self }
|
|
1138
|
+
/// Poll summary {pollId, sessionId, question, options[{id,text,count}], total, closed, ...} after a vote or close.
|
|
1139
|
+
@discardableResult public func onHopPollVoteUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopPollVoteUpdated, callback: cb); return self }
|
|
1140
|
+
/// Broadcast a whiteboard drawing delta to other hop participants.
|
|
1141
|
+
@discardableResult public func hopWhiteboardSync(_ data: [String: Any]) -> LiveChattaSocketAPI { emit(Events.hopWhiteboardSync, data: data, callback: nil); return self }
|
|
1142
|
+
@discardableResult public func onHopWhiteboardDelta(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopWhiteboardDelta, callback: cb); return self }
|
|
1143
|
+
|
|
1144
|
+
/// Listen for authentication errors (invalid/expired token).
|
|
1145
|
+
@discardableResult public func onAuthError(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.authError, callback: cb); return self }
|
|
1146
|
+
|
|
1147
|
+
/// Listen for chat errors
|
|
1148
|
+
@discardableResult
|
|
1149
|
+
public func onError(_ callback: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI {
|
|
1150
|
+
listen(Events.chatError, callback: callback)
|
|
1151
|
+
return self
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
/// Listen for SDK connect event
|
|
1155
|
+
@discardableResult
|
|
1156
|
+
public func onConnect(_ callback: @escaping () -> Void) -> LiveChattaSocketAPI {
|
|
1157
|
+
client?.on(LiveChattaClient.eventConnected) { _ in callback() }
|
|
1158
|
+
return self
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
/// Listen for SDK disconnect event
|
|
1162
|
+
@discardableResult
|
|
1163
|
+
public func onDisconnect(_ callback: @escaping (String) -> Void) -> LiveChattaSocketAPI {
|
|
1164
|
+
client?.on(LiveChattaClient.eventDisconnected) { data in
|
|
1165
|
+
let reason = (data as? [String: Any])?["reason"] as? String ?? "unknown"
|
|
1166
|
+
callback(reason)
|
|
1167
|
+
}
|
|
1168
|
+
return self
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
/// Listen for SDK reconnect event
|
|
1172
|
+
@discardableResult
|
|
1173
|
+
public func onReconnect(_ callback: @escaping (Int) -> Void) -> LiveChattaSocketAPI {
|
|
1174
|
+
client?.on(LiveChattaClient.eventReconnected) { data in
|
|
1175
|
+
let attempt = (data as? [String: Any])?["attempt"] as? Int ?? 0
|
|
1176
|
+
callback(attempt)
|
|
1177
|
+
}
|
|
1178
|
+
return self
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/// Listen for SDK reconnecting event
|
|
1182
|
+
@discardableResult
|
|
1183
|
+
public func onReconnecting(_ callback: @escaping (Int) -> Void) -> LiveChattaSocketAPI {
|
|
1184
|
+
client?.on(LiveChattaClient.eventReconnecting) { data in
|
|
1185
|
+
let attempt = (data as? [String: Any])?["attempt"] as? Int ?? 0
|
|
1186
|
+
callback(attempt)
|
|
1187
|
+
}
|
|
1188
|
+
return self
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
/// Remove listener(s) for an event
|
|
1192
|
+
@discardableResult
|
|
1193
|
+
public func off(_ event: String) -> LiveChattaSocketAPI {
|
|
1194
|
+
socket.off(event)
|
|
1195
|
+
return self
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
// MARK: - Chat features
|
|
1199
|
+
|
|
1200
|
+
/// { conversationId, messageIds (≤100) } — ack delivery of messages you didn't send
|
|
1201
|
+
public func messageDelivered(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1202
|
+
emit(Events.messageDelivered, data: data, callback: callback)
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
/// { conversationId, messageId, nextCursor?, limit? } — seen-by list
|
|
1206
|
+
public func messageInfo(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1207
|
+
emit(Events.messageInfo, data: data, callback: callback)
|
|
1208
|
+
}
|
|
1209
|
+
|
|
1210
|
+
/// { conversationId, duration: 1h|8h|1w|forever|off }
|
|
1211
|
+
public func muteConversation(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1212
|
+
emit(Events.muteConversation, data: data, callback: callback)
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
/// { enabled, start: HH:mm, end: HH:mm, timezone }
|
|
1216
|
+
public func updateQuietHours(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1217
|
+
emit(Events.updateQuietHours, data: data, callback: callback)
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
/// { conversationId, messageId, kind: remind|read_later, preset?, remindAt?, note? }
|
|
1221
|
+
public func setMessageReminder(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1222
|
+
emit(Events.setMessageReminder, data: data, callback: callback)
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/// { reminderId }
|
|
1226
|
+
public func cancelMessageReminder(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1227
|
+
emit(Events.cancelMessageReminder, data: data, callback: callback)
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
/// { conversationId, membersCan*?, slowModeSeconds?, allowScreenshots?, isPrivate? }
|
|
1231
|
+
public func updateConversationPermissions(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1232
|
+
emit(Events.updateConversationPermissions, data: data, callback: callback)
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1235
|
+
/// { conversationId, initialMediaKind? } — then joinHop for media
|
|
1236
|
+
public func huddleStart(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1237
|
+
emit(Events.huddleStart, data: data, callback: callback)
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
/// { conversationId }
|
|
1241
|
+
public func huddleStatus(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1242
|
+
emit(Events.huddleStatus, data: data, callback: callback)
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
/// { conversationId } — host/co-host or conversation admin
|
|
1246
|
+
public func huddleEnd(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1247
|
+
emit(Events.huddleEnd, data: data, callback: callback)
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
/// { conversationId, messageId } — failures arrive as transcript.errorCode
|
|
1251
|
+
public func transcribeMessage(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1252
|
+
emit(Events.transcribeMessage, data: data, callback: callback)
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1255
|
+
public func onMessageDelivered(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.messageDelivered, callback: cb); return self }
|
|
1256
|
+
public func onConversationMuted(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.conversationMuted, callback: cb); return self }
|
|
1257
|
+
public func onQuietHoursUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.quietHoursUpdated, callback: cb); return self }
|
|
1258
|
+
public func onMessageRemindersChanged(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.messageRemindersChanged, callback: cb); return self }
|
|
1259
|
+
public func onMessageReminderDue(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.messageReminderDue, callback: cb); return self }
|
|
1260
|
+
public func onConversationPermissionsUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.conversationPermissionsUpdated, callback: cb); return self }
|
|
1261
|
+
public func onHuddleUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.huddleUpdated, callback: cb); return self }
|
|
1262
|
+
/// A chat peer set or cleared their /status or /away
|
|
1263
|
+
public func onStatusUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.statusUpdated, callback: cb); return self }
|
|
1264
|
+
/// A live-location point moved
|
|
1265
|
+
public func onLiveLocationUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.liveLocationUpdated, callback: cb); return self }
|
|
1266
|
+
/// A live-location share ended
|
|
1267
|
+
public func onLiveLocationEnded(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.liveLocationEnded, callback: cb); return self }
|
|
1268
|
+
/// A connected calendar moved a meeting you are in: { conversationId, startAt, endAt, title }
|
|
1269
|
+
public func onHopMeetingUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopMeetingUpdated, callback: cb); return self }
|
|
1270
|
+
public func onMessageTranscriptUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.messageTranscriptUpdated, callback: cb); return self }
|
|
1271
|
+
public func onInboxUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.inboxUpdated, callback: cb); return self }
|
|
1272
|
+
|
|
1273
|
+
// MARK: - Chat core + Hop collab emitters (ack = callback payload)
|
|
1274
|
+
|
|
1275
|
+
/// { conversationId } — zero your unread count; ack { conversationId, unreadCount, lastReadAt }
|
|
1276
|
+
public func conversationRead(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1277
|
+
emit(Events.conversationRead, data: data, callback: callback)
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
/// { conversationId, messageId } — mark unread from that message; ack { conversationId, unreadCount, lastReadAt }
|
|
1281
|
+
public func conversationUnread(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1282
|
+
emit(Events.conversationUnread, data: data, callback: callback)
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
/// Unread per lane for rows you have not loaded; ack ["unreadTotals": { total, active, archived, people, groups, channels, saved }]
|
|
1286
|
+
public func getUnreadTotals(excludeConversationIds: [String] = [], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1287
|
+
let ids = Array(excludeConversationIds.prefix(Sidebar.maxExcludeIds))
|
|
1288
|
+
emit(Events.unreadTotals, data: ["excludeConversationIds": ids], callback: callback)
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
/// { conversationId, messageId, scope: me|everyone } — everyone: sender ≤48 h or admins
|
|
1292
|
+
public func deleteMessage(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1293
|
+
emit(Events.deleteMessage, data: data, callback: callback)
|
|
1294
|
+
}
|
|
1295
|
+
|
|
1296
|
+
/// { q (2–64), scope?: all|messages|conversations|people, nextCursor? }
|
|
1297
|
+
public func searchAll(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1298
|
+
emit(Events.searchAll, data: data, callback: callback)
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
/// { conversationId, name?, email?, phone?, topic? } — validated against the link's fields
|
|
1302
|
+
public func submitPreChat(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1303
|
+
emit(Events.submitPreChat, data: data, callback: callback)
|
|
1304
|
+
}
|
|
1305
|
+
|
|
1306
|
+
/// { sessionId, pollId } — host or poll starter; ack { ok, poll }
|
|
1307
|
+
public func hopPollClose(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1308
|
+
emit(Events.hopPollClose, data: data, callback: callback)
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
/// { sessionId } — polls, hands, captions and recording state on (re)join
|
|
1312
|
+
public func hopCollabState(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1313
|
+
emit(Events.hopCollabState, data: data, callback: callback)
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
/// { sessionId, enabled } — the room gets hop-captions-state
|
|
1317
|
+
public func hopCaptionsToggle(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1318
|
+
emit(Events.hopCaptionsToggle, data: data, callback: callback)
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1321
|
+
/// { sessionId, text, final?, lang? } — one speech-to-text line while captions are on
|
|
1322
|
+
public func hopCaption(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1323
|
+
emit(Events.hopCaption, data: data, callback: callback)
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
/// { conversationId, nextCursor?, limit? (≤20) } — ack { ok, results, nextCursor, hasMore }
|
|
1327
|
+
/// {} — ack { results: [{ id, name, url, width, height, animated, useCount, mine, uploadedByMe, source }] }
|
|
1328
|
+
public func stickersMine(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1329
|
+
emit(Events.stickersMine, data: data, callback: callback)
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
/// { q?, nextCursor? } — ack { results, nextCursor, hasMore }
|
|
1333
|
+
public func stickersSearch(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1334
|
+
emit(Events.stickersSearch, data: data, callback: callback)
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
/// { image (data URI, 64–512 px, ≤512 KB), name (2–40), tags? } — ack { sticker }
|
|
1338
|
+
public func stickerUpload(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1339
|
+
emit(Events.stickerUpload, data: data, callback: callback)
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
/// { stickerId } — ack { ok }
|
|
1343
|
+
public func stickerAdd(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1344
|
+
emit(Events.stickerAdd, data: data, callback: callback)
|
|
1345
|
+
}
|
|
1346
|
+
|
|
1347
|
+
/// { stickerId, everywhere? (uploader only) } — ack { ok }
|
|
1348
|
+
public func stickerRemove(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1349
|
+
emit(Events.stickerRemove, data: data, callback: callback)
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
/// { intentId, actionId, code?, conversationId } — the result arrives on onChattaMoneyCard
|
|
1353
|
+
public func chattaMoneyConfirm(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1354
|
+
emit(Events.chattaMoneyConfirm, data: data, callback: callback)
|
|
1355
|
+
}
|
|
1356
|
+
|
|
1357
|
+
/// 1.7.0: { kind: request | split | pot | paylink, id } — ack is the card (members of its chat, or the two people in a request)
|
|
1358
|
+
public func getMoneyCard(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1359
|
+
emit(Events.moneyCardGet, data: data, callback: callback)
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
/// 1.7.0: { conversationId, kind, id, action: pay | decline | cancel | contribute | close | refund | wallet | card | block, amount? (the server takes the chat from the card, so conversationId is optional) } — money-moving taps answer on onChattaMoneyCard
|
|
1363
|
+
public func moneyCardAction(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1364
|
+
emit(Events.moneyCardAction, data: data, callback: callback)
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
/// { conversationId, qaId } — host/admin; ack { conversationId, qaId, attendeeId, promoted }
|
|
1368
|
+
public func webinarQaAnswerLive(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1369
|
+
emit(Events.webinarQaAnswerLive, data: data, callback: callback)
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
/// { conversationId, qaId } — upvote; the room gets webinar-qa-updated
|
|
1373
|
+
public func webinarQaVote(_ data: [String: Any] = [:], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1374
|
+
emit(Events.webinarQaVote, data: data, callback: callback)
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
public func hopRecordingList(_ data: [String: Any], callback: (([String: Any]?) -> Void)? = nil) {
|
|
1378
|
+
emit(Events.hopRecordingList, data: data, callback: callback)
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
// Support inbox listeners (agents only): note events carry { conversationId, note | noteId, action? }
|
|
1382
|
+
@discardableResult public func onInternalNote(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.internalNote, callback: cb); return self }
|
|
1383
|
+
@discardableResult public func onInternalNoteDeleted(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.internalNoteDeleted, callback: cb); return self }
|
|
1384
|
+
@discardableResult public func onConversationNotesUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.conversationNotesUpdated, callback: cb); return self }
|
|
1385
|
+
/// CSAT card rated or replaced: { conversationId, messageId, csat, rating? (agents only, with the comment) }
|
|
1386
|
+
@discardableResult public func onCsatUpdated(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.csatUpdated, callback: cb); return self }
|
|
1387
|
+
|
|
1388
|
+
// Chat core listeners; onThreadUpdate = thread-messages { type: thread_update, replier? }
|
|
1389
|
+
@discardableResult public func onConversationRead(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.conversationRead, callback: cb); return self }
|
|
1390
|
+
@discardableResult public func onConversationUnread(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.conversationUnread, callback: cb); return self }
|
|
1391
|
+
@discardableResult public func onMessageDeleted(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.messageDeleted, callback: cb); return self }
|
|
1392
|
+
@discardableResult public func onPreChatSubmitted(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.preChatSubmitted, callback: cb); return self }
|
|
1393
|
+
@discardableResult public func onThreadUpdate(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.threadMessages, callback: cb); return self }
|
|
1394
|
+
|
|
1395
|
+
// Hop live captions
|
|
1396
|
+
@discardableResult public func onHopCaptionsState(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopCaptionsState, callback: cb); return self }
|
|
1397
|
+
@discardableResult public func onHopCaptionText(_ cb: @escaping ([String: Any]) -> Void) -> LiveChattaSocketAPI { listen(Events.hopCaptionText, callback: cb); return self }
|
|
1398
|
+
|
|
1399
|
+
// MARK: - Internal
|
|
1400
|
+
|
|
1401
|
+
internal func flushQueue() {
|
|
1402
|
+
guard !queue.isEmpty else { return }
|
|
1403
|
+
client?.log("Flushing \(queue.count) queued emits")
|
|
1404
|
+
let pending = queue
|
|
1405
|
+
queue.removeAll()
|
|
1406
|
+
client?.emitLifecycleEvent(LiveChattaClient.eventQueueFlush, data: ["count": pending.count])
|
|
1407
|
+
|
|
1408
|
+
for item in pending {
|
|
1409
|
+
emit(item.event, data: item.data, callback: item.callback)
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
// MARK: - Private
|
|
1414
|
+
|
|
1415
|
+
private func emit(_ event: String, data: [String: Any], callback: (([String: Any]?) -> Void)?) {
|
|
1416
|
+
if socket.status == .connected {
|
|
1417
|
+
socket.emitWithAck(event, data).timingOut(after: 15) { [weak self] items in
|
|
1418
|
+
let response = items.first as? [String: Any]
|
|
1419
|
+
// Denied calls ack { error }; never hand that to the callback as a success payload.
|
|
1420
|
+
if let denied = response?["error"], !(denied is NSNull) {
|
|
1421
|
+
self?.onAckError?(event, denied)
|
|
1422
|
+
callback?(nil)
|
|
1423
|
+
} else {
|
|
1424
|
+
callback?(response)
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
} else {
|
|
1428
|
+
client?.log("Queuing emit: \(event)")
|
|
1429
|
+
queue.append(QueuedEmit(event: event, data: data, callback: callback))
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
private func listen(_ event: String, callback: @escaping ([String: Any]) -> Void) {
|
|
1434
|
+
socket.on(event) { data, _ in
|
|
1435
|
+
if let dict = data.first as? [String: Any] {
|
|
1436
|
+
callback(dict)
|
|
1437
|
+
} else if let str = data.first as? String,
|
|
1438
|
+
let jsonData = str.data(using: .utf8),
|
|
1439
|
+
let dict = try? JSONSerialization.jsonObject(with: jsonData) as? [String: Any] {
|
|
1440
|
+
callback(dict)
|
|
1441
|
+
} else {
|
|
1442
|
+
callback([:])
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
}
|