// Use whatever decoder for your message contents.
var enc = System.Text.Encoding.UTF8;
_socket.ReceivedMatchState += newState =>
{
var contentmsg = enc.GetString(newState.State);
switch (newState.OpCode)
{
case 101:
Debug.LogFormat("User '{0}'' sent '{1}'", newState.UserPresence.Username, contentmsg);
RunOnUnityThread(() => {
// Do Unity stuff
Debug.Log("is this working ? user send message");
StartCoroutine(ChatNotificationProcess(newState.UserPresence.Username, contentmsg));
});
break;
default:
Debug.LogFormat("User '{0}'' sent '{1}'", newState.UserPresence.Username, contentmsg);
RunOnUnityThread(() => {
// Do Unity stuff
Debug.Log("is this working ? user send message");
StartCoroutine(ChatNotificationProcess(newState.UserPresence.Username, contentmsg));
});
break;
}
};
var match = await _socket.JoinMatchAsync(Player.PVP.MatchID);
foreach (var presence in match.Presences)
{
Debug.LogFormat("MATCH INFO : User id '{0}' name '{1}'.", presence.UserId, presence.Username);
if (presence.Username != username)
{
var newState = new Dictionary<string, string> { { "chatmessage", presence.Username + " join to the Match" } }.ToJson();
StartCoroutine(ChatNotificationProcess("Server", (string)newState));
newState = new Dictionary<string, string> { { "chatmessage", username + " join to the Match" } }.ToJson();
StartCoroutine(ChatNotificationProcess("Server", (string)newState));
}
}
The players join fine , but i dont know why im not receiving anything on the callback
i have the chat message code this way
var opCode = 101;
var newState = new Dictionary<string, string> { { "chatmessage", message } }.ToJson();
await socket.SendMatchStateAsync(MatchID, opCode, newState);
I dont see any red error so i dont know whats going on wish some body can guide me so i can debug and see whats going on? thanks
@PabloMonfort Are you using relayed matches, or authoritative? If you’re using relayed do not expect the message to be echoed back to you - it will only be sent to other users in the match, excluding the sender.
We are using authoritative, its created in the server side the match then users recieve the matchid from server and then both join, but im not receiving anything on here
_socket.ReceivedMatchState += newState =>
{
var contentmsg = enc.GetString(newState.State);
switch (newState.OpCode)
{
case 101:
Debug.LogFormat("User '{0}'' sent '{1}'", newState.UserPresence.Username, contentmsg);
RunOnUnityThread(() => {
// Do Unity stuff
Debug.Log("is this working ? user send message");
StartCoroutine(ChatNotificationProcess(newState.UserPresence.Username, contentmsg));
});
break;
default:
Debug.LogFormat("User '{0}'' sent '{1}'", newState.UserPresence.Username, contentmsg);
RunOnUnityThread(() => {
// Do Unity stuff
Debug.Log("is this working ? user send message");
StartCoroutine(ChatNotificationProcess(newState.UserPresence.Username, contentmsg));
});
break;
}
};
so you understand now my problem ? coz i cant understand whats going on, even the try stuff dosnt return anything so i dont have idea whats going on or why not send messages, both users are joined , i have fix all the auth code fixed for reconnection sockets etc , but this part still is not working to me and cant understand why , any hint? thanks
Even if was the case zyro thats not the case btw, none of the two players recieve anything so i dont know what you mean with that echoed coz i cant recieve none message not even a log to understand whats going on with try catch :S
we are using the Go example , maby its coz i didnt add notifications to the player from the matchloop? or something like that? sorry im trying to understand im new to go lang
i noticed that our match loop is not broadcasting anything back, can you be too gentleman and help me to get work
func (m *Match) MatchLoop(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, dispatcher runtime.MatchDispatcher, tick int64, state interface{}, messages []runtime.MatchData) interface{} {
return state
}
this my matchLoop on server , but i dont know how to send a broadcast dispatcher in go there is no example about this, there is one in lua but no in go and im kind lost on how i can send a message coz we was using rpc for other things and now i believe we need to use this match loop and avoid rpc avoid notifications too for game since we shuold handle a timer and turn based multiplayer game , i wish to can have more information to learn the Go part of this match Api of nakama and i think you guys are doing very well you should be proud of your work . any help its apprecciated thanks .
i confirm , your code fixed all the problems i was having with this part , very thanks zyro. so people if have same problem then me this is the way to go .