Пример #1
0
 private void PrintHeader(PacketHeader header)
 {
     Debug.Log(header.GetMagic());
     Debug.Log(header.GetVersion());
     Debug.Log(header.GetLength());
     Debug.Log(header.GetPacketType());
 }
Пример #2
0
    public void OnPacketReceived(Packet packet)
    {
        PacketHeader header = packet.GetHeader();

        string type = header.GetPacketType();

        if (type == "INIT")
        {
            Debug.Log("Received INIT packet. Reloading the scene...");
            PrintHeader(header);


            // We have to use the main thread to schedule this work.
            // Ideally, this entire callback should be running on the main thread.
            // This will do for now.

            // https://wiki.appodeal.com/en/unity/run-callbacks-in-main-unity-thread

            UnityMainThreadDispatcher.Instance().Enqueue(LoadGLB(packet.GetPayload()));
        }
        else if (type == "UPDT")
        {
            Debug.Log("Update packet received");
        }
        else if (type == "TRNS")
        {
            Debug.Log("Trans packet received");
        }
        else
        {
            Debug.Log("Problem: This packet type is not supported! Something has gone wrong.");
            PrintHeader(header);
        }
    }