//Overload Constructor - safe way to get variables public IrcConnect(string IP, int Port, string Username, string Password, string Channel, SimpleIRC sirc) { newIP = IP; newPort = Port; newUsername = Username; newPassword = Password; newChannel = Channel; simpleirc = sirc; isConnectionEstablised = false; dcc = new DCCClient(simpleirc, this); }
//overload constructor public DCCClient(SimpleIRC sirc, IrcConnect ircCon) { simpleirc = sirc; ircConnect = ircCon; }
//creates a thread for the pinger public Pinger(SimpleIRC sirc, IrcConnect ircCon) { simpleirc = sirc; ircConnect = ircCon; pingSender = new Thread(new ThreadStart(this.Run)); }
/// <Main> /// <summary> /// Prompts user with the options for saving a log file and printing log messages to the console window /// After that, it sets the default download directory /// Following it checks the current operating system, and performs actions related to the operating system, see '<RunningPlatform>' /// After that, it tries to locate all already downloaded files /// Then initiates the IRC client for later usage /// And after all that, starts the http servers (see class for more information) /// </summary /// </Main> static void Main(string[] args) { Console.WriteLine("Do you want to save debug messages to a log file? (Yes/No) (Left Empty means No): "); string shouldSaveDebug = Console.ReadLine(); if (shouldSaveDebug.ToLower().Contains("yes")) { saveDebug = true; } else{ saveDebug = false; } Console.WriteLine("Do you want to show debug messages in console? (Yes/No) (Left Empty means No): "); string shouldShowDebug = Console.ReadLine(); if (shouldShowDebug.ToLower().Contains("yes")) { showDebug = true; } else { showDebug = false; } Console.WriteLine("URL To use in your webbrowser: " + GetLocalIPAddress() + ":" + port.ToString()); SetupDownloadDir(Directory.GetCurrentDirectory() + @"/Downloads/"); RunningPlatform(); GetCurrentFiles(); irc = new SimpleIRC(); webserver = new HttpServer(HttpMessageReceived, port); webserver.SetWebHomeDir(Directory.GetCurrentDirectory() + @"/Views"); webserver.SetFileDir(Directory.GetCurrentDirectory() + "/Downloads"); webserver.SetDefaultPage("index.html"); streamserver = new HttpServer(HttpMessageReceived, port+1); streamserver.SetWebHomeDir(Directory.GetCurrentDirectory() + @"/Downloads"); streamserver.SetFileDir(Directory.GetCurrentDirectory() + "/Downloads"); streamserver.SetDefaultPage("index.html"); while (true) { string toSend = Console.ReadLine(); if(toSend != "") { if(toSend == "curanime"){ ParseAnimeSeason("http://myanimelist.net/anime/season", "current"); Console.WriteLine("starting to parse anime!"); } else { webserver.SendMessage(toSend); } } } }
static void Main(string[] args) { //setup vars string ip; int port; string username; string password; string channel; //setup screen: Console.WriteLine("Server IP(default is : 54.229.0.87(irc.rizon.net)) = "); if ((ip = Console.ReadLine()) == "") { ip = "54.229.0.87"; } Console.WriteLine("Server Port(default is : 6667) = "); if (Console.ReadLine() != "") { port = Convert.ToInt32(Console.ReadLine()); } else { port = 6667; } Console.WriteLine("Username(default is : RareIRC_Client) = "); if ((username = Console.ReadLine()) == "") { username = "******"; } Console.WriteLine("Password(not working yet, default is : ) = "); if ((password = Console.ReadLine()) == "") { password = ""; } Console.WriteLine("Channel(default is : #RareIRC) = "); if ((channel = Console.ReadLine()) == "") { channel = "#RareIRC"; } irc = new SimpleIRC(); irc.setupIrc(ip, port, username, password, channel, chatOutputCallback); irc.setDebugCallback(debugOutputCallback); irc.startClient(); irc.setDownloadStatusChangeCallback(downloadStatusChanged); while (true) { string Input = Console.ReadLine(); if (Input != null || Input != "" || Input != String.Empty) { irc.sendMessage(Input); } if (!irc.isClientRunning()) { Console.WriteLine("CLIENT NOT RUNNING :S"); break; } } }
private void Start_Click(object sender, EventArgs e) { SetupDownloadDir(Directory.GetCurrentDirectory() + @"/Downloads/"); RunningPlatform(); GetCurrentFiles(); irc = new SimpleIRC(); webserver = new HttpServer(HttpMessageReceived, port); webserver.SetWebHomeDir(Directory.GetCurrentDirectory() + @"/"); webserver.SetFileDir(Directory.GetCurrentDirectory() + "/Downloads"); webserver.SetDefaultPage("index.html"); streamserver = new HttpServer(HttpMessageReceived, port + 1); streamserver.SetWebHomeDir(Directory.GetCurrentDirectory() + @"/Downloads"); streamserver.SetFileDir(Directory.GetCurrentDirectory() + "/Downloads"); streamserver.SetDefaultPage("index.html"); State.Text = "Running (" + GetLocalIPAddress() + ":" + port.ToString() + ")"; }