Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to unpack messages too #543

Merged
merged 1 commit into from
Mar 4, 2019

Conversation

paulpach
Copy link
Contributor

@paulpach paulpach commented Mar 4, 2019

Provide a convenient method for unpacking messages. This is useful for OnServerAddPlayer.

This is how you call AddPlayer:

class Credentials : MessageBase
{
     public string username;
     public string password;
}

// now add a player
Credentials credentials = new Credentials() 
{
      username = "Joe",
      password = "Gabagaba"
};
client.AddPlayer(connection,  MessagePacker.pack(credentials));


// and this is how you receive it:
public override void OnServerAddPlayer(NetworkConnection conn, AddPlayerMessage extraMessage)
{
    Credentials credentials = MessagePacker.Unpack<Credentials>(extraMessage.value);
    ...
}

This PR also adds a unit test for packing/unpacking

@paulpach paulpach merged commit 9a0af7c into MirrorNetworking:master Mar 4, 2019
@miwarnec
Copy link
Collaborator

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@paulpach paulpach deleted the unpack branch March 27, 2019 12:17
github-actions bot referenced this pull request in MirageNet/Mirage Jan 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants