Skip to content
This repository was archived by the owner on Nov 23, 2024. It is now read-only.
This repository was archived by the owner on Nov 23, 2024. It is now read-only.

Matchmaking fails trying to deserialize missing fields #25

@mneilly

Description

@mneilly

I'm trying to perform matchmaking and running into a DeJson failure due to missing keys:

ERROR nakama_rs::web_socket: handle_message: Failed to parse json: Json Deserialize error: Key not found party_id, line:1 col:404

The call to add_matchmaker is as follows:

let match_maker = Matchmaker {
    min_count: 2,
    max_count: 2,
    string_properties: Default::default(),
    numeric_properties: Default::default(),
    query: "*".to_string(),
};
let ticket = web_socket.add_matchmaker(&match_maker).await;

If I modify socket.rs to add the #[nserde(default)] attribute to the appropriate field in MatchmakerUser the failure mode moves on to the same issue with string_properties and numeric_properties.

Adding the attribute to all three as follows enables the matchmaking to proceed:

#[derive(DeJson, SerJson, Debug, Clone, Default)]
pub struct MatchmakerUser {
    pub presence: UserPresence,
    #[nserde(default)]
    pub party_id: String,
    #[nserde(default)]
    pub string_properties: HashMap<String, String>,
    #[nserde(default)]
    pub numeric_properties: HashMap<String, f64>,
}

After the above, similar errors occur for the authoritative and label fields in Match. Adding default attributes to these allow the matchmaking and match joining to proceed. Not sure if the applied default values are appropriate.

The full exchange of messages is as follows:

2022-03-23T04:04:11.833334Z DEBUG nakama_rs::web_socket_adapter: Connection with 127.0.0.1 now open
2022-03-23T04:04:11.848743Z TRACE nakama_rs::web_socket: on_received:
{
  "status_presence_event": {
    "joins": [
      {
        "user_id": "18cab496-20c6-4113-9149-6c822c5a8378",
        "session_id": "4be110b2-aa5e-11ec-8116-7106fdcb5b46",
        "username": "adMhRsMqYS",
        "status": ""
      }
    ]
  }
}
handle_message: Received message:
{
  "status_presence_event": {
    "joins": [
      {
        "user_id": "18cab496-20c6-4113-9149-6c822c5a8378",
        "session_id": "4be110b2-aa5e-11ec-8116-7106fdcb5b46",
        "username": "adMhRsMqYS",
        "status": ""
      }
    ]
  }
}
2022-03-23T04:04:11.979399Z TRACE nakama_rs::web_socket: send: Sending message:
{
  "cid": "1",
  "matchmaker_add": {
    "min_count": 2,
    "max_count": 2,
    "query": "*",
    "string_properties": {
    },
    "numeric_properties": {
    }
  }
}
2022-03-23T04:04:11.995599Z TRACE nakama_rs::web_socket: on_received:
{
  "cid": "1",
  "matchmaker_ticket": {
    "ticket": "9e28f7fd-831c-4024-b717-282e8feda656"
  }
}
handle_message: Received message:
{
  "cid": "1",
  "matchmaker_ticket": {
    "ticket": "9e28f7fd-831c-4024-b717-282e8feda656"
  }
}
2022-03-23T04:04:11.995642Z TRACE nakama_rs::web_socket: handle_message: Received message with cid
2022-03-23T04:04:23.864773Z TRACE nakama_rs::web_socket: on_received:
{
  "matchmaker_matched": {
    "ticket": "9e28f7fd-831c-4024-b717-282e8feda656",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDgwMDgyOTMsIm1pZCI6ImRkNDRiODg1LTgyZGItNDFlZi1iNjc1LWQ1NDQ4ZjI3YjUwZC4ifQ.ibXJaOgMFFmaPmUbeR0MZkJQJx7m-TdbdccrB-dvSx4",
    "users": [
      {
        "presence": {
          "user_id": "88dec33f-7cfb-4ae9-ab65-02f052d9c915",
          "session_id": "490489e7-aa5e-11ec-8116-7106fdcb5b46",
          "username": "yIbmOcxeKr"
        }
      },
      {
        "presence": {
          "user_id": "18cab496-20c6-4113-9149-6c822c5a8378",
          "session_id": "4be110b2-aa5e-11ec-8116-7106fdcb5b46",
          "username": "adMhRsMqYS"
        }
      }
    ],
    "self": {
      "presence": {
        "user_id": "18cab496-20c6-4113-9149-6c822c5a8378",
        "session_id": "4be110b2-aa5e-11ec-8116-7106fdcb5b46",
        "username": "adMhRsMqYS"
      }
    }
  }
}
handle_message: Received message:
{
  "matchmaker_matched": {
    "ticket": "9e28f7fd-831c-4024-b717-282e8feda656",
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NDgwMDgyOTMsIm1pZCI6ImRkNDRiODg1LTgyZGItNDFlZi1iNjc1LWQ1NDQ4ZjI3YjUwZC4ifQ.ibXJaOgMFFmaPmUbeR0MZkJQJx7m-TdbdccrB-dvSx4",
    "users": [
      {
        "presence": {
          "user_id": "88dec33f-7cfb-4ae9-ab65-02f052d9c915",
          "session_id": "490489e7-aa5e-11ec-8116-7106fdcb5b46",
          "username": "yIbmOcxeKr"
        }
      },
      {
        "presence": {
          "user_id": "18cab496-20c6-4113-9149-6c822c5a8378",
          "session_id": "4be110b2-aa5e-11ec-8116-7106fdcb5b46",
          "username": "adMhRsMqYS"
        }
      }
    ],
    "self": {
      "presence": {
        "user_id": "18cab496-20c6-4113-9149-6c822c5a8378",
        "session_id": "4be110b2-aa5e-11ec-8116-7106fdcb5b46",
        "username": "adMhRsMqYS"
      }
    }
  }
}
2022-03-23T04:04:23.864954Z ERROR nakama_rs::web_socket: handle_message: Failed to parse json: Json Deserialize error: Key not found party_id, line:1 col:404

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions