コード例 #1
0
        /// <summary>
        /// Initialize component, or destroy if an active instance of it already
        /// exists.
        /// </summary>
        void Awake()
        {
            if (net != null)
            {
                Destroy(this);
                return;
            }

            net = this;
            DontDestroyOnLoad(net);

            packetExecutor = GetComponent <IPacketExecutorContext>();

            packetQueue = new PacketQueue();
            client      = new Client("localhost", port, packetQueue);
        }
コード例 #2
0
        public void HandlePackets(IPacketExecutorContext context)
        {
            IPacket packet;

            while (true)
            {
                lock (packets)
                {
                    if (packets.Count == 0)
                    {
                        return;
                    }
                    packet = packets.First.Value;
                    packets.RemoveFirst();
                }

                packet.Handle(context);
            }
        }
コード例 #3
0
 /// <inheritdoc/>
 public void Handle(IPacketExecutorContext context)
 {
     // We should never recieve a handshake packet from a server.
 }
コード例 #4
0
 /// <inheritdoc/>
 public void Handle(IPacketExecutorContext context)
 {
     // TODO Update scene in Unity.
 }