heroiclabs / nakama-rs

Apache License 2.0
69 stars 13 forks source link

Panic in ApiClient.tick when deserializing match_data message if op_code doesn't exist #8

Open wlinna opened 3 years ago

wlinna commented 3 years ago

OR maybe the title should be: op_code isn't serialized when set to zero.

I'm sending message like this: client.socket_send(op_code, &msg::SpawnWiz { x: 0.0, y: 0.0 });

If op_code is 0, the message gets serialized to this:

{
    "match_data": {
        "match_id": "032b1d6c-b0c0-418b-bad5-8d85ecd92cdf.",
        "presence": {
            "user_id": "0a84ef9e-63fb-4f16-b33b-3d5772db4e60",
            "session_id": "3b5d3fcf-b7a0-11eb-945c-7106fdcb5b46",
            "username": "u1621318437"
        },
        "data": "AAAAAAAAAAA="
    }
}

The lack of op_code causes a panic in ApiClient.tick. If I change op_code to 1, the panic doesn't happen.

I'm using nakama-rs from GitHub and the latest nakama image from DockerHub. My version of nanoserde is 0.1.25.