Exemplo n.º 1
0
        public void ConnectTo(Server toServer, Credentials credentials)
        {
            this.server = toServer;

            string inputLine;
            try
            {
                var serverConnectionStarted = new ServerConnectionStarted {ServerConnection = this};
                eventAggregator.Raise(serverConnectionStarted);

                irc = new TcpClient(toServer.Address, toServer.Port);
                stream = irc.GetStream();
                reader = new StreamReader(stream, Encoding.Default);
                writer = new StreamWriter(stream);

                var serverAddress = toServer.Address;

                ping = new PingSender(ref writer, ref serverAddress);
                ping.Start();

                SendCredentials(credentials);

                // Odotetaan viestejä
                while ((inputLine = reader.ReadLine()) != null)
                {
                    ProcessIncomingMessage(inputLine);
                }

                // Suljetaan streamit
                writer.Close();
                reader.Close();
                irc.Close();

            }
            catch (Exception e)
            {
                Thread.Sleep(1000);
            }
        }
Exemplo n.º 2
0
 public void ConnectToServer(Server server, Credentials credentials)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 3
0
 public void ConnectToServer(Server server, Credentials botCredentials)
 {
     this.credentials = botCredentials;
     connection.ConnectTo(server, botCredentials);
 }
Exemplo n.º 4
0
 private void ConnectBot(Bot bot, Server server)
 {
     var credentials = new Credentials("USER Bottii 0 * :Botti", "IrcBotNM");
     bot.ConnectToServer(server, credentials);
 }
Exemplo n.º 5
0
        /// <summary>
        /// Returns a Network-array about the known irc-networks.
        /// </summary>
        /// <returns>Array of irc-networks and addresses</returns>
        public System.Collections.ArrayList GetNetworks()
        {
            // Gets the known networks
            var networksDataSet = this.dataSourceConnection.GetNetworks();
            var networks = new System.Collections.ArrayList();

            // Now get the servers
            foreach (System.Data.DataRow dr in networksDataSet.Tables[0].Rows)
            {
                var networkID = Int32.Parse(dr["network_id"].ToString().TrimEnd());
                var name = dr["name"].ToString().TrimEnd();
                var description = dr["description"].ToString().TrimEnd();
                var network = new Network(networkID, name, description);

                System.Data.DataSet serversDataSet = this.dataSourceConnection.GetServers(networkID);
                foreach (System.Data.DataRow dr2 in serversDataSet.Tables[0].Rows)
                {
                    var server_address = dr2["address"].ToString().TrimEnd();
                    var server_description = dr2["description"].ToString().TrimEnd();
                    var server_port = Int32.Parse(dr2["port"].ToString().TrimEnd());
                    var server = new Server(server_address, server_port, server_description);
                    network.AddServer(server);
                }
                networks.Add (network);
            }
            return networks;
        }
Exemplo n.º 6
0
 /// <summary>
 /// Adds a new server to network
 /// </summary>
 /// <param name="server">Server-object</param>
 public void AddServer(Server server)
 {
     this.servers.Add(server);
 }