Example #1
0
    private void OnMessageRecieved(object data)
    {
        byte[] bytes          = (byte[])data;
        byte   messageVersion = (byte)bytes[0];

        GPMPEvents.Types command = (GPMPEvents.Types)BitConverter.ToInt32(bytes, 1);
        EventManager.TriggerEvent(command.ToString(), bytes);
        //DebugMP.Log("Message recieved from other player. Version: " + (byte)bytes[0] + "\t" + "Event type: " + command.ToString());
    }
Example #2
0
    void SendMessage(GPMPEvents.Types eventType, List <byte> message)
    {
        //DebugMP.Log("Sending message to opponent version: " + protocolVersion + "\t" + "Event type: " + eventType.ToString());
        List <byte> m = new List <byte>();

        m.Add(protocolVersion);                            // first byte is the version
        m.AddRange(BitConverter.GetBytes((int)eventType)); // second to fifth byte is the event
        m.AddRange(message);
        byte[] messageToSend = m.ToArray();
        PlayGamesPlatform.Instance.RealTime.SendMessage(false, matchModel.opponent.ParticipantId, messageToSend);
        protocolVersion++;
    }