public static void Main( string[] args )
{
m_Assembly = Assembly.GetEntryAssembly();
/* print a banner */
Version ver = m_Assembly.GetName().Version;
Console.WriteLine("SunLogin Version {0}.{1}.{2} http://www.sunuo.org/",
ver.Major, ver.Minor, ver.Revision);
Console.WriteLine(" on {0}, runtime {1}",
Environment.OSVersion, Environment.Version);
if ((int)Environment.OSVersion.Platform == 128)
Console.WriteLine("Please make sure you have Mono 1.1.7 or newer! (mono -V)");
Console.WriteLine();
/* prepare SunUO */
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler( CurrentDomain_UnhandledException );
AppDomain.CurrentDomain.ProcessExit += new EventHandler( CurrentDomain_ProcessExit );
if (args.Length > 0) {
Console.WriteLine("SunLogin does not understand command line arguments");
return;
}
string baseDirectory = Path.GetDirectoryName(ExePath);
string confDirectory = new DirectoryInfo(baseDirectory)
.CreateSubdirectory("etc").FullName;
config = new Config.Root(baseDirectory,
Path.Combine(confDirectory, "sunuo.xml"));
Directory.SetCurrentDirectory(config.BaseDirectory);
m_Thread = Thread.CurrentThread;
if ( m_Thread != null )
m_Thread.Name = "Core Thread";
if ( BaseDirectory.Length > 0 )
Directory.SetCurrentDirectory( BaseDirectory );
Timer.TimerThread ttObj = new Timer.TimerThread();
timerThread = new Thread( new ThreadStart( ttObj.TimerMain ) );
timerThread.Name = "Timer Thread";
if (!config.Exists)
config.Save();
m_MessagePump = new MessagePump();
foreach (IPEndPoint ipep in Config.Network.Bind)
m_MessagePump.AddListener(new Listener(ipep));
timerThread.Start();
NetState.Initialize();
Encryption.Initialize();
ServerList.Initialize();
ServerQueryTimer.Initialize();
Server.Accounting.AccountHandler.Initialize();
EventSink.InvokeServerStarted();
log.Info("SunLogin initialized, entering main loop");
try
{
while ( !m_Closing )
{
m_Signal.WaitOne();
Timer.Slice();
m_MessagePump.Slice();
NetState.FlushAll();
NetState.ProcessDisposedQueue();
}
}
catch ( Exception e )
{
CurrentDomain_UnhandledException( null, new UnhandledExceptionEventArgs( e, true ) );
}
if ( timerThread.IsAlive )
timerThread.Abort();
}