Beispiel #1
0
        private void registerServerButton_Click(object sender, EventArgs e)
        {
            burraForm = new BurraForm();
            burraForm.Show(this);

            string ipAddress = addressTextBox.Text.Trim();
            Protocol protocol = protocolComboBox.SelectedIndex == 0 ? Protocol.TCP : Protocol.HTTP;
            int port = int.Parse(portTextBox.Text.Trim());
            string serverName = serverNameTextBox.Text.Trim();
            EndPointInfo endPointInfo = new EndPointInfo(serverName, ipAddress, protocol, port);

            registOnServerWorker.RunWorkerAsync(endPointInfo);
        }
Beispiel #2
0
        void IPeerToUser.RegisterOnServer(EndPointInfo serverInfo)
        {
            ((IPeerToUser)this).UnregisterFromServer();

            string protocol = null;

            switch (serverInfo.Protocol)
            {
                case Protocol.HTTP:
                    protocol = "http";
                    break;
                //case Protocol.IPC:
                //    protocol = "ipc";
                //    break;
                case Protocol.TCP:
                    protocol = "tcp";
                    break;
            }

            string url = String.Concat(protocol, "://", serverInfo.Address, ":", serverInfo.Port, "/",
                serverInfo.Name);

            peerServer = (IPeerDiscovery)Activator.GetObject(
              typeof(IPeerDiscovery),
              url);

            peerServer.RegistPeer(this);

            continueThread.Reset();
            updateRenewThread = new Thread(new ThreadStart(UpdateRenew));
            updateRenewThread.Start();

            connectedToServer = true;
        }