コード例 #1
0
        /// <summary>
        /// Creates a <see cref="ClientConnectionContainer"/> and connects it to the given IP address and port.
        /// </summary>
        /// <param name="ipAddress">The IP address to connect to.</param>
        /// <param name="port">The port to connect to.</param>
        /// <returns>The created <see cref="ClientConnectionContainer"/>.</returns>
        public static ClientConnectionContainer CreateClientConnectionContainer(string ipAddress, int port)
        {
            var clientConnectionContainer = new ClientConnectionContainer(ipAddress, port);

            clientConnectionContainer.Initialize();
            return(clientConnectionContainer);
        }
コード例 #2
0
        /// <summary>
        /// Creates a <see cref="ClientConnectionContainer"/> with the given <see cref="TcpConnection"/> and <see cref="UdpConnection"/>.
        /// </summary>
        /// <param name="tcpConnection">The <see cref="TcpConnection"/> to use.</param>
        /// <param name="udpConnection">The <see cref="UdpConnection"/> to use.</param>
        /// <returns>The created <see cref="ClientConnectionContainer"/>.</returns>
        /// <exception cref="ArgumentException">Thrown if the given <see cref="TcpConnection"/> is not connected.</exception>
        public static ClientConnectionContainer CreateClientConnectionContainer(TcpConnection tcpConnection, UdpConnection udpConnection)
        {
            if (tcpConnection == null || !tcpConnection.IsAlive)
            {
                throw new ArgumentException("TCP connection must be connected to an endpoint.");
            }

            var clientConnectionContainer = new ClientConnectionContainer(tcpConnection, udpConnection);

            clientConnectionContainer.Initialize();
            return(clientConnectionContainer);
        }
コード例 #3
0
 public static void SendMessge(this ClientConnectionContainer client, string Tag, object data)
 {
     client.Send(RawDataConverter.FromUTF8String(Tag, data.ToJson()));
 }