ArtemisComm.PacketProcessing.StartServerConnection C# (CSharp) Method

StartServerConnection() private method

private StartServerConnection ( ) : void
return void
        public void StartServerConnection()
        {
            if (IsConnectedToClients)
            {
                throw new InvalidOperationException("Cannot set up a server connection when already listening on clients.");
            }

            IsConnectedToServer = true;


            Connector conn = new Connector(Port);

            connections.Add(conn.ID, conn);

            TcpClient client = new TcpClient();

            Subscribe(conn);
            try
            {

                client.Connect(Host, Port);

                conn.Start(client);
                OnEvent(NewConnectionCreated, new ConnectionEventArgs(conn.ID));
            }
            catch (SocketException)
            {
                if (UnableToConnect != null)
                {
                    UnableToConnect(this, EventArgs.Empty);
                }
            }
            catch (Exception)
            {
                if (CrashOnException)
                {
                    throw;
                }
            }
        }
        public event EventHandler UnableToConnect;

Usage Example

        private void OnConnect(object sender, RoutedEventArgs e)
        {
            string host = Host.Text;
            connector = new PacketProcessing();


            ConnectorSubscribe();
            connector.SetPort(2010);
            connector.SetServerHost(host);
            connector.StartServerConnection();

        }
All Usage Examples Of ArtemisComm.PacketProcessing::StartServerConnection