private void buttonStartServer_Click(object sender, EventArgs e)
        {
            if (team1Box.Text != "" && team2Box.Text != "")
            {
                buttonStartServer.Enabled = false;
                team1Box.Enabled          = false;
                team2Box.Enabled          = false;
                server.ConnectionClosed  += Server_ConnectionClosed;
                server.DataReceived      += Server_DataReceived;
                server.DataTransferred   += Server_DataTransferred;
                server.errEncounter      += ServerErrEncounter;
                server.onConnection      += ServerOnConnection;
                server.StartConnection();
                rtbConOut.AppendText(Environment.NewLine);

                teamOptions.Add(team1Box.Text);
                teamOptions.Add(team2Box.Text);
                DisplayInformation("Started Server with Team1 as " + teamOptions[0].ToString() + " and team2 as " + teamOptions[1].ToString());

                arduino.PortName = SerialConnections.Text;
                arduino.Open();
            }
            else
            {
                DisplayInformation("ERROR TEAM NAMES CAN NOT BE NULL");
            }
        }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Server = new NetComm.Host(2020);
     Server.StartConnection();
     client               = new NetComm.Client();
     client.Connected    += new NetComm.Client.ConnectedEventHandler(client_Connected);
     client.Disconnected += new NetComm.Client.DisconnectedEventHandler(client_Disconnected);
     client.DataReceived += new NetComm.Client.DataReceivedEventHandler(client_DataReceived);
 }
Example #3
0
 private void MainDisplay_Load(object sender, EventArgs e)
 {
     Server = new NetComm.Host(2020); //Initialize the Server object, connection will use the 2020 port number
     Server.StartConnection();        //Starts listening for incoming clients
     //Adding event handling methods, to handle the server messages
     Server.onConnection   += new NetComm.Host.onConnectionEventHandler(Server_onConnection);
     Server.lostConnection += new NetComm.Host.lostConnectionEventHandler(Server_lostConnection);
     Server.DataReceived   += new NetComm.Host.DataReceivedEventHandler(Server_DataReceived);
     Cxo();
 }
Example #4
0
        private ArrayList clientList = new ArrayList(); // Share amongst all instances of the Clients

        public Form1()
        {
            InitializeComponent();
            server.ConnectionClosed += Server_ConnectionClosed;
            server.DataReceived     += Server_DataReceived;
            server.DataTransferred  += Server_DataTransferred;
            server.errEncounter     += ServerErrEncounter;
            server.lostConnection   += ServerLostConnection;
            server.onConnection     += ServerOnConnection;
            server.StartConnection();
            rtbConOut.AppendText(Environment.NewLine);
        }
Example #5
0
        public void Init()
        {
            server = new Host(8080);
            server.StartConnection();

            server.NoDelay           = true;
            server.ReceiveBufferSize = 100;
            server.SendBufferSize    = 100;

            server.onConnection   += Server_onConnection;
            server.lostConnection += Server_lostConnection;
            server.DataReceived   += Server_DataReceived;

            Console.WriteLine("Сервер запущен. Ожидание подключений...");
        }
Example #6
0
        /// <summary>
        /// Start The server and Setup initial variables and connections
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmServer_Load(object sender, EventArgs e)
        {
            // Get Azure Server Name, Table Name, User name and Password

            FrmAzureDatabaseLogin AzureLogin = new FrmAzureDatabaseLogin();
            DialogResult          dr         = AzureLogin.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                AzureDB.SQLInfoMessage  += AzureDB_SQLInfoMessage;  // Get any messages from the SQL Database
                AzureDB.SQLStateChanged += AzureDB_SQLStateChanged; // Keep track of Database Connection Changes

                AzureDB.ConnectionString = "Server=tcp:" + AzureLogin.ServerName + ";Database=ChatApp;User ID=" + AzureLogin.UserName + ";Password="******";Trusted_Connection=False;Encrypt=True;Connection Timeout=30;";
                if (AzureDB.Connect())
                {
                    // Display our Public IP Address and the port we are listening to.
                    pip = new PublicIP();
                    pip.PublicIPKnown += pip_PublicIPKnown; // Get's the Public IP Address of the Server (Event)
                    pip.PublicIPError += pip_PublicIPError; // Notifies us of any Errors Getting the Public IP
                    pip.GetPublicIpAddress();               // Will Raise the above event
                    lblPort.Text = OurPort.ToString();

                    // Subscribe to Server Events
                    server.ConnectionClosed += server_ConnectionClosed;
                    server.DataReceived     += server_DataReceived;
                    server.DataTransferred  += server_DataTransferred;
                    server.errEncounter     += server_errEncounter;
                    server.lostConnection   += server_lostConnection;
                    server.onConnection     += server_onConnection;
                    server.StartConnection(); // Don't forget to start your server !!

                    // Now get total number of Registered Users.
                    TotalRegisteredUsers = AzureDB.GetRegisteredUsers();
                    UpdateTotalRegisteredUsers(TotalRegisteredUsers);
                }
                else
                {
                    MessageBox.Show("Azure Database Error: " + AzureDB.LastError);
                    lblConnectionState.Image = ServerClientChat1._3.Properties.Resources.database_red;
                }
            }
            else
            {
                MessageBox.Show("The Server cannot run unless connected to the Server's Azure SQL Database \n\rClosing Application");
                this.Close();
            }
        }
 private void NewToolStripMenuItemClick(object sender, EventArgs e)
 {
     server.StartConnection();
     lblConnectionStatusImage.Image = Properties.Resources.green_circle_md;
 }