コード例 #1
0
        /// <summary>
        /// Gets available virtual server API infos.
        /// </summary>
        /// <returns></returns>
        public DataSet GetVirtualServerAPIs()
        {
            /* GetVirtualServerAPIs Responses:
             +OK <sizeOfData>
             *      <data>
             *
             + ERR <errorText>
             */

            lock (m_pParent){
                // Call TCP GetVirtualServerAPIs
                m_pParent.TcpClient.TcpStream.WriteLine("GetVirtualServerAPIs");

                string response = m_pParent.ReadLine();
                if (!response.ToUpper().StartsWith("+OK"))
                {
                    throw new Exception(response);
                }

                int          sizeOfData = Convert.ToInt32(response.Split(new char[] { ' ' }, 2)[1]);
                MemoryStream ms         = new MemoryStream();
                m_pParent.TcpClient.TcpStream.ReadFixedCount(ms, sizeOfData);

                // Decompress dataset
                DataSet ds = Utils.DecompressDataSet(ms);

                return(ds);
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets server events and binds them to this.
        /// </summary>
        private void Bind()
        {
            /* GetEvents
             *    Responses:
             +OK <sizeOfData>
             *      <data>
             *
             *      -ERR <errorText>
             */

            lock (m_pOwner){
                // Call TCP GetEvents
                m_pOwner.TcpClient.TcpStream.WriteLine("GetEvents");

                string response = m_pOwner.ReadLine();
                if (!response.ToUpper().StartsWith("+OK"))
                {
                    throw new Exception(response);
                }

                int          sizeOfData = Convert.ToInt32(response.Split(new char[] { ' ' }, 2)[1]);
                MemoryStream ms         = new MemoryStream();
                m_pOwner.TcpClient.TcpStream.ReadFixedCount(ms, sizeOfData);

                // Decompress dataset
                DataSet ds = Utils.DecompressDataSet(ms);

                if (ds.Tables.Contains("Events"))
                {
                    foreach (DataRow dr in ds.Tables["Events"].Rows)
                    {
                        m_pEvents.Add(new Event(
                                          dr["ID"].ToString(),
                                          (EventType_enum)Convert.ToInt32(dr["Type"]),
                                          dr["VirtualServer"].ToString(),
                                          Convert.ToDateTime(dr["CreateDate"]),
                                          dr["Text"].ToString(),
                                          dr["Text"].ToString()
                                          ));
                    }
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets server events and binds them to this.
        /// </summary>
        private void Bind()
        {
            /* GetSessions
             *    Responses:
             +OK <sizeOfData>
             *      <data>
             *
             *      -ERR <errorText>
             */

            lock (m_pOwner.LockSynchronizer){
                // Call TCP GetEvents
                m_pOwner.TcpClient.TcpStream.WriteLine("GetSessions");

                string response = m_pOwner.ReadLine();
                if (!response.ToUpper().StartsWith("+OK"))
                {
                    throw new Exception(response);
                }

                int          sizeOfData = Convert.ToInt32(response.Split(new char[] { ' ' }, 2)[1]);
                MemoryStream ms         = new MemoryStream();
                m_pOwner.TcpClient.TcpStream.ReadFixedCount(ms, sizeOfData);

                // Decompress dataset
                DataSet ds = Utils.DecompressDataSet(ms);

                if (ds.Tables.Contains("Sessions"))
                {
                    foreach (DataRow dr in ds.Tables["Sessions"].Rows)
                    {
                        m_pSessions.Add(new Session(
                                            this,
                                            dr["SessionID"].ToString(),
                                            dr["SessionType"].ToString(),
                                            Convert.ToDateTime(dr["SessionStartTime"]),
                                            Convert.ToInt32(dr["ExpectedTimeout"]),
                                            dr["UserName"].ToString(),
                                            dr["LocalEndPoint"].ToString(),
                                            dr["RemoteEndPoint"].ToString(),
                                            Convert.ToInt32(dr["ReadTransferRate"]),
                                            Convert.ToInt32(dr["WriteTransferRate"]),
                                            dr["SessionLog"].ToString()
                                            ));
                    }
                }
            }
        }