Example #1
0
        public async Task ArmaUpdatePosition(ArmaMessage message)
        {
            if (message.Timestamp < DateTime.UtcNow.AddMinutes(-1))
            {
                _logger.LogTrace("Too old, skip");
                return; // Too old !
            }

            var state = GetState(ConnectionKind.Arma);

            if (state == null)
            {
                _logger.LogWarning($"No state for ArmaUpdatePosition");
                return;
            }

            var x       = ArmaSerializer.ParseDouble(message.Args[0]) ?? 0d;
            var y       = ArmaSerializer.ParseDouble(message.Args[1]) ?? 0d;
            var z       = ArmaSerializer.ParseDouble(message.Args[2]) ?? 0d;
            var dir     = ArmaSerializer.ParseDouble(message.Args[3]) ?? 0d;
            var date    = ArmaSerializer.ParseIntegerArray(message.Args[4]);
            var grp     = ArmaSerializer.ParseString(message.Args[5]);
            var vehicle = message.Args.Length > 6 ? ArmaSerializer.ParseString(message.Args[6]) : null;

            state.LastSetPosition = new SetPositionMessage()
            {
                X         = x,
                Y         = y,
                Altitude  = z,
                Heading   = dir,
                Date      = ToDateTime(date),
                Timestamp = message.Timestamp,
                Group     = grp,
                Vehicle   = vehicle
            };

            await Clients.Group(state.WebChannelName).SendAsync("SetPosition", state.LastSetPosition);
        }
Example #2
0
        public async Task ArmaStartMission(ArmaMessage message)
        {
            var state = GetState(ConnectionKind.Arma);

            if (state == null)
            {
                Console.WriteLine($"No state for ArmaStartMission");
                return;
            }

            var worldName = ArmaSerializer.ParseString(message.Args[0]);
            var size      = ArmaSerializer.ParseDouble(message.Args[1]) ?? 0d;
            var date      = ArmaSerializer.ParseIntegerArray(message.Args[2]);

            state.LastMission = new MissionMessage()
            {
                WorldName = worldName,
                Size      = size,
                Date      = ToDateTime(date),
                Timestamp = message.Timestamp
            };

            await Clients.Group(state.WebChannelName).SendAsync("Mission", state.LastMission);
        }