doorbash / colyseus-kotlin-java-example

A demo project to show how to work with colyseus-kotlin in Java
https://github.com/doorbash/colyseus-kotlin
3 stars 0 forks source link

joinOrCreate : System.err: at io.colyseus.serializer.SchemaSerializer.handshake(SchemaSerializer.kt:42) #1

Closed hdev72 closed 2 years ago

hdev72 commented 2 years ago

hello dear friend im getting error when using java example in joinOrCreate: java.lang.reflect.InvocationTargetException

doorbash commented 2 years ago

Hi @hdev72 Are you getting this error while using the newest version of colyseus-kotlin (0.14.5) ? Java example is outdated

hdev72 commented 2 years ago

Yes im using kotlin repo Error InvocationTargetException happening when state class has invalid SchemaField And now this error solved but now im getting new error in parmessage of incaming server message: Room > parseMessage

hdev72 commented 2 years ago

joinOrCreate onError returns java.lang.Exception

private fun parseMessage(bytes: ByteArray) { . . . in below code im getting this error java.lang.NullPointerException:

Protocol.JOIN_ROOM -> { var offset = 1 val serializerId = String(bytes, offset + 1, bytes[offset].toInt() and 0xFF) offset += serializerId.length + 1 if (serializerId == "fossil-delta") { throw Error("fossil-delta is not supported") } if (bytes.size > offset) { serializer.handshake(bytes, offset) } onJoin?.invoke() connection?._send(Protocol.JOIN_ROOM) }

. . .

}

doorbash commented 2 years ago

@hdev72 I've updated dependencies in latest commits. I wasn't able to reproduce. The example works fine for me.

hdev72 commented 2 years ago

@doorbash yes dear milad , i tested and for me working fine too, just one time getting error serilizer but in my android app allways when client receives first message (state change or ...) getting this error :

W/System.err: java.lang.NullPointerException W/System.err: at io.colyseus.serializer.SchemaSerializer.handshake(SchemaSerializer.kt:42) W/System.err: at io.colyseus.Room.parseMessage(Room.kt:92) W/System.err: at io.colyseus.Room.access$parseMessage(Room.kt:20) W/System.err: at io.colyseus.Room$connect$3.invoke(Room.kt:75) W/System.err: at io.colyseus.Room$connect$3.invoke(Room.kt:20) W/System.err: at io.colyseus.Connection.onMessage(Connection.kt:66) W/System.err: at org.java_websocket.client.WebSocketClient.onWebsocketMessage(WebSocketClient.java:598) W/System.err: at org.java_websocket.drafts.Draft_6455.processFrameBinary(Draft_6455.java:862) W/System.err: at org.java_websocket.drafts.Draft_6455.processFrame(Draft_6455.java:821) W/System.err: at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:379) W/System.err: at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:216) W/System.err: at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:506) W/System.err: at java.lang.Thread.run(Thread.java:761) W/System.err: java.lang.Exception W/System.err: at io.colyseus.Client$createMatchMakeRequest$2$1.invoke(Client.kt:316) W/System.err: at io.colyseus.Client$createMatchMakeRequest$2$1.invoke(Client.kt:19) W/System.err: at io.colyseus.Room.parseMessage(Room.kt:148) W/System.err: at io.colyseus.Room.access$parseMessage(Room.kt:20) W/System.err: at io.colyseus.Room$connect$3.invoke(Room.kt:75) W/System.err: at io.colyseus.Room$connect$3.invoke(Room.kt:20) W/System.err: at io.colyseus.Connection.onMessage(Connection.kt:66) W/System.err: at org.java_websocket.client.WebSocketClient.onWebsocketMessage(WebSocketClient.java:598) W/System.err: at org.java_websocket.drafts.Draft_6455.processFrameBinary(Draft_6455.java:862) W/System.err: at org.java_websocket.drafts.Draft_6455.processFrame(Draft_6455.java:821) W/System.err: at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:379) W/System.err: at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:216) W/System.err: at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:506) W/System.err: at java.lang.Thread.run(Thread.java:761) E/htag: join ranked exception: java.lang.Exception

server side message: Room created! onJoin onLeave(_qhCCQUna)

hdev72 commented 2 years ago

i think if you update your https://github.com/doorbash/colyseus-android-chat repository will see this error

//implementation 'ir.doorbash:colyseus-java:2.3.3'
implementation "io.github.doorbash:colyseus-kotlin:0.14.5"
hdev72 commented 2 years ago

i just updated implementation 'ir.doorbash:colyseus-java:2.3.3' to implementation "io.github.doorbash:colyseus-kotlin:0.14.5" in your android chat example and getting above error

you can download and test dear friend: https://apphteam.com/colyseus-android-chat-master_test_new_version.rar

i should use new version (kotlin:0.14.5) because old version (ir.doorbash:colyseus-java:2.3.3) have a bug: when server sending consecutive messages, previusCode in messageParser some times has another value for example receiving message is state change protocol but previusCode is not equals with receiving new protocol code number

Thanks for your help to solve this issue👍

doorbash commented 2 years ago

Hi @hdev72 I have just updated colyseus-android-chat with the new changes let me know if there were any issues with it

hdev72 commented 2 years ago

@doorbash you right dear milad problem is in my changes thanks for your helps :X 👍