What is Opcode and how it works?

hi everyone, I’m new to Nakama and I want to understand Opcodes better, what are they and how can I set them, what type of data can be included in it and what is it’s relationship with sending and receiving messages??

I need some examples in code with c#

thanks in advance.

Please see the documentation on Op Codes and examples of how to use them.

what I’m understanding is that you have to set an Opcode for every action you want to transfer through the network, and you will also create a dictionary for that action in a set of key and values to give data to that action and then convert it to Json inside the MatchDataJson
and then you combine these two information inside the sendMatchState
we will give it the match id, the opcode and the state we created in the Json Data class
we can specify that in the player every time we want to send an action,

and now what is left for me to understand is the receiving part
what is " var state = matchState.State.Length > 0 ? System.Text.Encoding.UTF8.GetString(matchState.State).FromJson<Dictionary<string, string>>() : null; "
inside the onReceive function???

and what is the match state ???
does the “FromJson” part gives back the data we created inside the MatchDataJson class??
what does that part do??

The line of code you shared is checking to see if any state data is being received. If so, it turns it into a UTF8 encoded string and then parses it as a Dictionary<string, string> object.

For further information please see the Receiving match state documentation in our Unity Client Guide.