Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the FhemClient class.
 /// </summary>
 /// <param name="a_networkStreamReader"></param>
 /// <param name="a_networkStreamWriter"></param>
 /// <remarks>
 /// This constructor is intended for unit testing.
 /// </remarks>
 internal FhemClient(INetworkStreamReader a_networkStreamReader, INetworkStreamWriter a_networkStreamWriter)
 {
     //-- Initialize fields
     m_networkStreamReader = a_networkStreamReader;
     m_networkStreamWriter = a_networkStreamWriter;
     m_isConnected         = true;
 }
Beispiel #2
0
        /// <summary>
        /// Connects this Fhem client with a Fhem server.
        /// </summary>
        /// <param name="a_hostName">
        /// The host name of the Fhem server.
        /// </param>
        /// <param name="a_telnetPort">
        /// The Fhem server port where telnet is provided.
        /// </param>
        public void Connect(string a_hostName, int a_telnetPort)
        {
            //-- Create the TCP client
            m_tcpClient = new TcpClient(a_hostName, a_telnetPort);

            //-- Get the network stream and create the reader and writer instances
            var networkStream = m_tcpClient.GetStream();

            m_networkStreamReader = new NetworkStreamReader(networkStream);
            m_networkStreamWriter = new NetworkStreamWriter(networkStream);

            //-- Set a flag that we are connected
            this.IsConnected = true;
        }