-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathWebSocketClientModule.kt
More file actions
64 lines (50 loc) · 1.94 KB
/
WebSocketClientModule.kt
File metadata and controls
64 lines (50 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.mattermost.networkclient
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.ReactMethod
import com.facebook.react.bridge.ReadableMap
internal class WebSocketClientModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
private var implementation: WebSocketClientModuleImpl = WebSocketClientModuleImpl(reactContext)
override fun getName(): String = WebSocketClientModuleImpl.NAME
override fun invalidate() {
super.invalidate()
implementation.invalidate()
}
@ReactMethod
fun ensureClientFor(wsUrl: String, options: ReadableMap, promise: Promise) {
implementation.ensureClientFor(wsUrl, options, promise)
}
@ReactMethod
fun createClientFor(wsUrl: String, options: ReadableMap, promise: Promise) {
implementation.createClientFor(wsUrl, options, promise)
}
@ReactMethod
fun invalidateClientFor(wsUrl: String, promise: Promise) {
implementation.invalidateClientFor(wsUrl, promise)
}
@ReactMethod
fun connectFor(wsUrl: String, promise: Promise) {
implementation.connectFor(wsUrl, promise)
}
@ReactMethod
fun disconnectFor(wsUrl: String, promise: Promise) {
implementation.disconnectFor(wsUrl, promise)
}
@ReactMethod
fun sendDataFor(wsUrl: String, data: String, promise: Promise) {
implementation.sendDataFor(wsUrl, data, promise)
}
@ReactMethod
fun sendBinaryDataFor(wsUrl: String, data: String, promise: Promise) {
implementation.sendBinaryDataFor(wsUrl, data, promise)
}
@ReactMethod
fun addListener(eventName: String) {
// Keep: Required for RN built in Event Emitter Calls
}
@ReactMethod
fun removeListeners(count: Int) {
// Keep: Required for RN built in Event Emitter Calls
}
}