コード例 #1
0
    void OnReceivePacket(ushort type, Stream stream)
    {
        switch (type)
        {
        case (ushort)UserPacketType.Message:
            MessagePacket messagePacket = new MessagePacket();
            messagePacket.Deserialize(stream);

            if (ConnectionManager.Instance.isServer)
            {
                MessageManager.Instance.SendString(messagePacket.payload, 0);
            }

            messages.text += messagePacket.payload + System.Environment.NewLine;
            break;

        case (ushort)UserPacketType.Position:
            PositionPacket positionPacket = new PositionPacket();
            positionPacket.Deserialize(stream);

            if (ConnectionManager.Instance.isServer)
            {
                MessageManager.Instance.SendPosition(positionPacket.payload, 0);
            }

            // Aca enviaria el payload a donde sea necesario
            break;
        }
    }
コード例 #2
0
 void OnReceivePacket(ushort type, Stream stream)
 {
     switch (type)
     {
     case (ushort)UserPacketType.Message:
         MessagePacket messagePacket = new MessagePacket();
         messagePacket.Deserialize(stream);
         text.text = messagePacket.payload;
         break;
     }
 }
コード例 #3
0
ファイル: InteractScript.cs プロジェクト: Lithiot/Multiplayer
    public void OnReceivePacket(ushort packetType, Stream stream, IPEndPoint ip)
    {
        if (packetType == (ushort)PacketType.Message)
        {
            MessagePacket message = new MessagePacket();

            message.Deserialize(stream);

            screenText.text += message.payload + System.Environment.NewLine;
        }
    }