示例#1
0
        /// <summary>
        /// List all conference room.
        /// </summary>
        /// <param name="roomlist">return conference room data list</param>
        /// <returns>true if query succeed.</returns>
        public bool GetConferenceList(out List <ConferenceRoom> roomlist)
        {
            string cmd  = "";
            string resp = "";

            roomlist = null;

            cmd  = "api conference list";
            resp = SendCommand(cmd);

            if (resp.IndexOf("No active conferences") >= 0)
            {
                return(false);
            }

            roomlist = new List <ConferenceRoom>();
            string[] text = Regex.Split(resp, "\\+OK");
            foreach (var item in text)
            {
                if (item == "")
                {
                    continue;
                }
                ConferenceRoom room;
                if (ConferenceRoom.TryParse(out room, item))
                {
                    roomlist.Add(room);
                }
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Parse ConferenceRoom struct by EventSocket responsed strings.
        /// </summary>
        /// <param name="room">parsed result</param>
        /// <param name="text">response string from EventSocket</param>
        /// <returns>parsing succeed or not?</returns>
        public static bool TryParse(out ConferenceRoom room, string text)
        {
            bool ok = false;

            room          = new ConferenceRoom();
            room.UserList = new List <ConferenceUser>();
            room.FlagList = new List <string>();
            try
            {
                using (var reader = new StringReader(text))
                {
                    string line  = reader.ReadLine();
                    var    match = Regex.Match(line, Pattern1);
                    if (match.Success)
                    {
                        room.ID        = match.Groups[1].Value;
                        room.VoiceRate = int.Parse(match.Groups[3].Value);
                        room.FlagList.AddRange(match.Groups[4].Value.Split('|'));

                        //read following lines by user counts
                        int count = int.Parse(match.Groups[2].Value);
                        for (int i = 0; i < count; i++)
                        {
                            line = reader.ReadLine();
                            ConferenceUser user;
                            if (ConferenceUser.TryParse(out user, line))
                            {
                                room.UserList.Add(user);
                            }
                        }
                        ok = true;
                    }
                }
            }
            catch (Exception ex)
            {
                ok = false;
            }

            return(ok);
        }