예제 #1
0
    void Update()
    {
        if (mainController != null)
        {
            // Check if new commands arrived
            if (lastUpdate != mainController.lastUpdate)
            {
                commands.Clear();
                try
                {
                    foreach (string c in mainController.commands)
                    {
                        commands.Add(c);
                    }
                    lastUpdate = mainController.lastUpdate;
                }
                catch
                {}
            }
        }
        // Deal with received commands
        foreach (string elem in commands)
        {
            try
            {
                string[] data = elem.Split(';');

                if (data.Length > 1)
                {
                    string command = data[0];
                    if (command == "EVENT_1.0")
                    {
                        string name        = data[1];
                        string status      = data[2];
                        string description = data[3];

                        Event e = new Event();
                        e.name        = name;
                        e.status      = status;
                        e.description = description;

                        events.Add(e);
                    }
                    if (command == "EVENT_BYSERVER1.0")
                    {
                        ByServer s = new ByServer();
                        s.server = data[1];
                        s.number = data[2];

                        byserver.Add(s);
                        if (byserver.Count > 10)
                        {
                            byserver.RemoveAt(0);
                        }
                    }
                    if (command == "EVENT_BYACCOUNT1.0")
                    {
                        ByAccount s = new ByAccount();
                        s.account = data[1];
                        s.number  = data[2];

                        byaccount.Add(s);
                        if (byaccount.Count > 10)
                        {
                            byaccount.RemoveAt(0);
                        }
                    }
                }
            }
            catch {}
        }

        if (commands.Count > 0)
        {
            commands.Clear();
        }
    }
예제 #2
0
    void Update()
    {
        if (mainController != null)
        {

            // Check if new commands arrived
            if (lastUpdate != mainController.lastUpdate)
            {
                commands.Clear();
                try
                {
                    foreach (string c in mainController.commands)
                    {
                        commands.Add(c);
                    }
                    lastUpdate = mainController.lastUpdate;
                }
                catch
                {}
            }
        }
        // Deal with received commands
        foreach (string elem in commands)
        {
            try
            {
            string[] data = elem.Split(';');

                if (data.Length > 1)
                {
                    string command = data[0];
                    if (command == "EVENT_1.0")
                    {
                        string name = data[1];
                        string status = data[2];
                        string description = data[3];

                        Event e = new Event();
                        e.name = name;
                        e.status = status;
                        e.description = description;

                        events.Add(e);
                    }
                    if (command == "EVENT_BYSERVER1.0")
                    {
                        ByServer s = new ByServer();
                        s.server = data[1];
                        s.number = data[2];

                        byserver.Add(s);
                        if (byserver.Count > 10)
                            byserver.RemoveAt(0);
                    }
                    if (command == "EVENT_BYACCOUNT1.0")
                    {
                        ByAccount s = new ByAccount();
                        s.account = data[1];
                        s.number = data[2];

                        byaccount.Add(s);
                        if (byaccount.Count > 10)
                            byaccount.RemoveAt(0);
                    }
                }
            }
            catch{}

        }

        if (commands.Count > 0)
        {
            commands.Clear();
        }
    }