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); } }
public void ConnectToServer(Server server, Credentials credentials) { throw new NotImplementedException(); }
public void ConnectToServer(Server server, Credentials botCredentials) { this.credentials = botCredentials; connection.ConnectTo(server, botCredentials); }
private void ConnectBot(Bot bot, Server server) { var credentials = new Credentials("USER Bottii 0 * :Botti", "IrcBotNM"); bot.ConnectToServer(server, credentials); }
/// <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; }
/// <summary> /// Adds a new server to network /// </summary> /// <param name="server">Server-object</param> public void AddServer(Server server) { this.servers.Add(server); }