Beispiel #1
0
        /// <summary>
        /// Creates a server from a ServerConfig with a parameter
        /// to provide an interface for logging.
        /// </summary>
        /// <param name="config">The configuration to build the Server from.</param>
        /// <param name="logFunction">The function to call to log text for the application.</param>
        public Server(Configuration.ServerConfig config, Project2QService.WriteLogFunction logFunction)
        {
            //Instantiate and load databases
            uc = new UserCollection();
            cc = new ChannelCollection();
            uc.LoadRegisteredUsers( "userdb\\" + config.Name + ".udb" );

            //Rip up this little guy to help us out :D
            currentHost = new IRCHost();
            currentIP = null;

            this.authmode = !File.Exists( "userdb\\" + config.Name + ".udb" );

            this.writeLogFunction = logFunction;

            //Assign a Server ID
            this.serverId = Server.NextServerId;
            if ( this.serverId == -1 ) throw new OverflowException( "Too many servers created." );
            servers[serverId] = this;

            //Save the configuration.
            this.config = config;

            //Tie default static handlers together for this instance of IRCEvents.
            irce = new IRCEvents();

            //Initialize the socket pipe before the modules. Modules are scary.
            state = State.Disconnected;

            socketPipe = new SocketPipe(
                this.serverId, config.RetryTimeout, config.OperationTimeout, config.SendInhibit, config.SocketBufferSize ); //Default values for now, get them from config later plz.
            socketPipe.OnDisconnect += new SocketPipe.NoParams( this.OnDisconnect );
            socketPipe.OnReceive += new SocketPipe.ReceiveData( this.OnReceive );
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            DateTime dt = DateTime.Now;
            Project2QService qq;
            Thread t;
            qq = new Project2QService( "../../../Config.xml", Console.In, Console.Out );
            t = new Thread( new ParameterizedThreadStart( qq.OnStart ) );
            t.Start( null );

            string input;
            do {
                input = Console.ReadLine();
                if ( input.StartsWith( "send " ) ) {
                    input = input.Remove( 0, "send ".Length );
                    Console.WriteLine("Sending {0}: {1}", input.Split( ' ' )[0] , input.Remove( 0, 2 ) );
                    qq.SendMessage( int.Parse( input.Split( ' ' )[0] ) , input.Remove( 0, 2 ) );
                }
                if ( input.Equals( "uptime" ) ) {
                    TimeSpan up = DateTime.Now - dt;
                    Console.WriteLine( up.ToString() );
                }
            } while ( !input.Equals("quit") );

            qq.OnStop();

            #if DEBUG
            Console.ReadKey(true);
            #endif
        }
Beispiel #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            CheckForIllegalCrossThreadCalls = false; //Proper way to do this? Probably not. But owell Q_Q

            ms = new MemoryStream( 1024 );
            sr = new StreamReader( ms );
            sw = new ThreadSafeStreamWriter( ms );

            sw.GotWrittenTo += new ThreadSafeStreamWriter.WrittenToDelegate( sw_GotWrittenTo );
            sw.AutoFlush = true;

            qq = new Project2QService( "../../../Config.xml", sr, sw );
            p2qthread = new Thread( new ParameterizedThreadStart( qq.OnStart ) );
            p2qthread.Start( null );
            icon.Visible = false;
        }
Beispiel #4
0
 /// <summary>
 /// Creates an Rcon Server with the ability to log.
 /// </summary>
 /// <param name="rconfig">An RConsole Configuration to build off.</param>
 /// <param name="writeLog">The function to call with logging information.</param>
 public Rcon(Configuration.RconConfig rconfig, Project2QService.WriteLogFunction writeLog)
     : this(rconfig)
 {
     writeLogFunction = writeLog;
 }