/// <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 ); }