Ejemplo n.º 1
0
        private void LockingCommandOnExecuted(ILockingCommand executedCommand)
        {
            executedCommand.Executed -= LockingCommandOnExecuted;
            lockingCommands.Remove(executedCommand);
            ActionsSemaphore.Unlock();

            var isClient = Loader.Instance.Network.IsClient;

            if (!isClient)
            {
                return;
            }
            var message = MessagesPool.Instance.GetMessage(
                ByteCompression.RequiredBytes <MessageType>());

            message.AddressKey = Key;
            message.Content.PushEnum <MessageType>((int)MessageType.LockingCommandExecuted);
            message.Type = DistributedMessageType.ReliableOrdered;
            BroadcastMessage(message);
        }
Ejemplo n.º 2
0
        public void RegisterNewCommand(ILockingCommand lockingCommand)
        {
            if (lockingCommands.Contains(lockingCommand))
            {
                return;
            }
            lockingCommands.Add(lockingCommand);
            lockingCommand.Executed += LockingCommandOnExecuted;
            ActionsSemaphore.Lock();

            //Lock master simulation foreach client
            var masterManager = Loader.Instance.Network.Master;

            if (masterManager != null)
            {
                foreach (var client in masterManager.Clients)
                {
                    ActionsSemaphore.Lock();
                }
            }
        }