示例#1
0
        private void ReceiveWebResponseBroadcastMessages(int code, string response)
        {
            if (response == null)
            {
                if (m_configData.print_errors)
                {
                    Puts("Couldn't get an answer from SSN service.");
                }
            }
            else if (code != 200)
            {
                if (m_configData.print_errors)
                {
                    Puts("SSN error (%code): %text".Replace("%code", code.ToString()).Replace("%text", response));
                }
            }

            JsonBroadcastMessages jsonBroadcastMessages = JsonConvert.DeserializeObject <JsonBroadcastMessages>(response);

            if (m_broadcastMessagesInterval != jsonBroadcastMessages.interval)
            {
                m_broadcastMessagesInterval = jsonBroadcastMessages.interval;
                if (m_broadcastMessagesInterval > 0)
                {
                    if (m_broadcastTimer == null)
                    {
                        m_broadcastTimer = timer.Repeat(m_broadcastMessagesInterval, 0, () => BroadcastNextMessage());
                    }
                    else
                    {
                        m_broadcastTimer.Reset(m_broadcastMessagesInterval, 0);
                    }
                }
            }
            m_broadcastMessages = jsonBroadcastMessages.messages;
        }