Skip to content

Commit afaaaa1

Browse files
committed
Fix Kotlin warns, show disconnect reason on error.
1 parent 43d9b97 commit afaaaa1

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

android/app/src/main/java/com/enderchat/modules/connection/ConnectionModule.kt

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import javax.crypto.Cipher
1818
import javax.crypto.spec.IvParameterSpec
1919
import javax.crypto.spec.SecretKeySpec
2020
import kotlin.concurrent.read
21-
import kotlin.concurrent.thread
2221
import kotlin.concurrent.write
2322

2423
class ConnectionModule(reactContext: ReactApplicationContext)
@@ -291,9 +290,9 @@ class ConnectionModule(reactContext: ReactApplicationContext)
291290
// Remove upstream listeners, stop unnecessary background tasks
292291
}
293292

294-
private fun println(log: Any?) {
293+
/* private fun println(log: Any?) {
295294
sendEvent(reactContext = reactApplicationContext, "ecm:log", Arguments.createMap().apply {
296295
putString("log", log.toString())
297296
})
298-
}
297+
} */
299298
}

src/minecraft/connection/javascript.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ const initiateJavaScriptConnection = async (opts: ConnectionOptions) => {
113113
})
114114
socket.on('error', err => {
115115
if (!resolved) reject(err)
116-
else conn.emit('error', err)
116+
else {
117+
conn.disconnectReason = err.message
118+
conn.emit('error', err)
119+
}
117120
})
118121
const lock = new Semaphore(1)
119122
socket.on('data', newData => {

src/minecraft/connection/native.ts

+1
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ export class NativeServerConnection
125125
this.eventEmitter.addListener('ecm:error', (event: NativeErrorEvent) => {
126126
if (event.connectionId !== this.id) return
127127
console.error(event.stackTrace)
128+
this.disconnectReason = event.message
128129
this.emit('error', new Error(event.message))
129130
})
130131
this.eventEmitter.addListener('ecm:close', (event: NativeEvent) => {

0 commit comments

Comments
 (0)