Esempio n. 1
0
        /// <summary>
        /// Play sound when recieving message with active alarm
        /// </summary>
        /// <param name="message"></param>
        /// <param name="socketWrapper"></param>
        private async void OnMessageAsync(string message, WebSocketWrapper socketWrapper)
        {
            var webSocketDefinition = new { globalAlarmId = "", active = true }; //active = true is active alarm
            var webSocketMessage    = message.GetJsonObject(webSocketDefinition);

            if (!_alreadyPlayed.Contains(webSocketMessage.globalAlarmId))
            {
                _alreadyPlayed.Add(webSocketMessage.globalAlarmId);
                var alarmInfo = await _httpRequest.GetAlarmInfo(webSocketMessage.globalAlarmId, _accesstoken);

                if (webSocketMessage.active && alarmInfo > 0)
                {
                    _soundService.PlaySound();
                }
            }
        }