示例#1
0
        private void UpdateCircle(PewCircleSettings circleSettings)
        {
            var existing = GetObjectById <PewCircle>(circleSettings.Id);

            if (existing != null)
            {
                _logger.LogInfo("CIRCLE: Updating existing, id: " + circleSettings.Id);
                existing.Initialize(circleSettings, false);
            }
            else
            {
                _logger.LogInfo("CIRCLE: Adding a new, id: " + circleSettings.Id);
                lock (objectsSynchro)
                {
                    _objects.Add(_stuffFactory.CreatePewCircle(circleSettings, false));
                }
            }
        }
示例#2
0
        private async Task WaitAndParseMessage()
        {
            NetworkMessage message = await _sender.GetAsync(_serverStream);

            _logger.LogInfo("Got a message: " + message.Type);

            switch (message.Type)
            {
            case NetworkMessageType.Welcome:
            {
                int id = message.Payload.DeSerializeJson <int>();
                // Not checking for null since if it is null, something very bad is happening.
                OnServerWelcome.Invoke(id);
                break;
            }

            case NetworkMessageType.UpdateLazers:
            {
                var lazers = message.Payload.DeSerializeJson <List <LazerPewPewSettings> >();
                // Not checking for null since if it is null, something very bad is happening.
                OnServerUpdateLazers.Invoke(lazers);
                break;
            }

            case NetworkMessageType.UpdateMe:
            {
                PewCircleSettings circleSettings = message.Payload.DeSerializeJson <PewCircleSettings>();
                _logger.LogInfo("Circle settings: " + message.Payload);

                // Not checking for null since if it is null, something very bad is happening.
                OnServerUpdateCircle(circleSettings);
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#3
0
 private void QueueUpdateCircle(PewCircleSettings circleSettings)
 {
     _netCircleSettings.Enqueue(circleSettings);
 }