Ejemplo n.º 1
0
 protected override void ProcessClientMessage(MessageType mt, Stream stm, Node n)
 {
     if (mt == MessageType.NEW_PLAYER_REQUEST)
     {
         Guid player = Serializer.Deserialize <Guid>(stm);
         OnNewPlayerRequest(player, n.info.remote);
     }
     else if (mt == MessageType.NEW_WORLD_REQUEST)
     {
         Point worldPos = Serializer.Deserialize <Point>(stm);
         OnNewWorldRequest(worldPos, null, 0);
     }
     else if (mt == MessageType.NEW_VALIDATOR)
     {
         OnNewValidator(n.info.remote.addr);
     }
     else if (mt == MessageType.RESPONSE)
     {
         RemoteAction.Process(remoteActions, n, stm);
     }
     else if (mt == MessageType.STOP_VALIDATING)
     {
         OnStopValidating(n);
     }
     else
     {
         throw new Exception("Client.ProcessClientMessage bad message type " + mt.ToString());
     }
 }
Ejemplo n.º 2
0
        protected override void ProcessWorldMessage(MessageType mt, Stream stm, Node n, WorldInfo inf)
        {
            if (mt == MessageType.LOCK_VAR)
            {
                Guid remoteActionId = Serializer.Deserialize <Guid>(stm);
                OnLock(n, remoteActionId);
            }
            else if (mt == MessageType.UNLOCK_VAR)
            {
                RemoteAction.Process(ref locked, n, stm);
                if (finalizing)
                {
                    MyAssert.Assert(locked == null);
                    OnFinalizedVerifier();
                }
            }
            else
            {
                if (finalizing)
                {
                    Log.Dump(info, " finalizing - ignored message:", mt);
                    return;
                }

                if (mt == MessageType.PICKUP_TELEPORT)
                {
                    ProcessOrDelay(OnPickupTeleport);
                }
                else if (mt == MessageType.PICKUP_BLOCK)
                {
                    ProcessOrDelay(OnPickupBlock);
                }
                else if (mt == MessageType.PLAYER_DISCONNECT)
                {
                    ProcessOrDelay(OnDisconnect);
                }
                else
                {
                    throw new Exception(Log.StDump(info, inf, mt, "unexpected message"));
                }
            }
        }