Exemple #1
0
        public ServerForm(string clientId, string serverId, string chordAddress, int chordPort)
        {
            InitializeComponent();
            statusBox.ReadOnly = true;
            string serverName = serverId;
            Config.Instance.ChooseClientSetOfReplicas(clientId);

            ServerConfig serverConfiguration = (Config.Instance.ServersConfiguration.Where(p => p.Name == serverId)).ToArray<ServerConfig>()[0];
            List<string> replicas = new List<string>((from p in Config.Instance.ServersConfiguration
                                                      where p.Name.Equals(serverId) != true
                                                      select p.Address + ":" + p.Port + "/" + p.Name).ToList<string>());
            this.Text += " @ " + serverConfiguration.Address + ":" + serverConfiguration.Port;
            PADIBook.Server.Server serv = new PADIBook.Server.Server(serverConfiguration.Name, serverConfiguration.Address, serverConfiguration.Port, replicas, chordAddress, chordPort);
            ServerManager.Instance.RegisterServer(serv);
            ServerManager.Instance.StartServer();
        }
Exemple #2
0
        public ServerForm(string clientId, string serverId, string chordAddress, int chordPort)
        {
            InitializeComponent();
            statusBox.ReadOnly = true;
            string serverName = serverId;

            Config.Instance.ChooseClientSetOfReplicas(clientId);

            ServerConfig  serverConfiguration = (Config.Instance.ServersConfiguration.Where(p => p.Name == serverId)).ToArray <ServerConfig>()[0];
            List <string> replicas            = new List <string>((from p in Config.Instance.ServersConfiguration
                                                                   where p.Name.Equals(serverId) != true
                                                                   select p.Address + ":" + p.Port + "/" + p.Name).ToList <string>());

            this.Text += " @ " + serverConfiguration.Address + ":" + serverConfiguration.Port;
            PADIBook.Server.Server serv = new PADIBook.Server.Server(serverConfiguration.Name, serverConfiguration.Address, serverConfiguration.Port, replicas, chordAddress, chordPort);
            ServerManager.Instance.RegisterServer(serv);
            ServerManager.Instance.StartServer();
        }
Exemple #3
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            if (!comboBox.Text.Equals(""))
            {
                try
                {
                    string serverName = comboBox.Text;
                    Config.Instance.ChooseClientSetOfReplicas(setComboBox.Text);

                    ServerConfig  serverConfiguration = (Config.Instance.ServersConfiguration.Where(p => p.Name == comboBox.Text)).ToArray <ServerConfig>()[0];
                    List <string> replicas            = new List <string>((from p in Config.Instance.ServersConfiguration
                                                                           where p.Name.Equals(comboBox.Text) != true
                                                                           select p.Address + ":" + p.Port + "/" + p.Name).ToList <string>());
                    AddressPort = serverConfiguration.Address + ":" + serverConfiguration.Port;

                    PADIBook.Server.Server serv;
                    if (includeChordNodeCheckBox.Checked)
                    {
                        if (chordNodeAddressTextBox.Text == "")
                        {
                            MessageBox.Show("Por favor insira um endereço para o nó do Chord.");
                            return;
                        }
                        serv = new PADIBook.Server.Server(serverConfiguration.Name, serverConfiguration.Address, serverConfiguration.Port, replicas, chordNodeAddressTextBox.Text, Int32.Parse(chordPortTextBox.Text));
                    }
                    else
                    {
                        serv = new PADIBook.Server.Server(serverConfiguration.Name, serverConfiguration.Address, serverConfiguration.Port, replicas);
                    }

                    ServerManager.Instance.RegisterServer(serv);
                    ServerManager.Instance.StartServer();
                    this.Close();
                }
                catch (FormatException)
                {
                    MessageBox.Show("Unable to parse port number.");
                }
            }
        }
Exemple #4
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            if (!comboBox.Text.Equals(""))
            {
                try
                {
                    string serverName = comboBox.Text;
                    Config.Instance.ChooseClientSetOfReplicas(setComboBox.Text);

                    ServerConfig serverConfiguration = (Config.Instance.ServersConfiguration.Where(p => p.Name == comboBox.Text)).ToArray<ServerConfig>()[0];
                    List<string> replicas = new List<string>((from p in Config.Instance.ServersConfiguration
                                                              where p.Name.Equals(comboBox.Text) != true
                                                              select p.Address + ":" + p.Port + "/" + p.Name).ToList<string>());
                    AddressPort = serverConfiguration.Address + ":" + serverConfiguration.Port;

                    PADIBook.Server.Server serv;
                    if (includeChordNodeCheckBox.Checked)
                    {
                        if (chordNodeAddressTextBox.Text == "")
                        {
                            MessageBox.Show("Por favor insira um endereço para o nó do Chord.");
                            return;
                        }
                        serv = new PADIBook.Server.Server(serverConfiguration.Name, serverConfiguration.Address, serverConfiguration.Port, replicas, chordNodeAddressTextBox.Text, Int32.Parse(chordPortTextBox.Text));
                    }
                    else
                    {
                        serv = new PADIBook.Server.Server(serverConfiguration.Name, serverConfiguration.Address, serverConfiguration.Port, replicas);
                    }

                    ServerManager.Instance.RegisterServer(serv);
                    ServerManager.Instance.StartServer();
                    this.Close();
                }
                catch (FormatException)
                {
                    MessageBox.Show("Unable to parse port number.");
                }
            }
        }
Exemple #5
0
 public void RegisterServer(Server server)
 {
     this.server = server;
 }