示例#1
0
 void client_OnDisconnect(object sender, SessionCloseEventArgs e)
 {
     Log.WriteLine(LogLevel.Error, "Disconnected from server.");
     this.client.OnPacket -= new EventHandler<InterPacketReceivedEventArgs>(client_OnPacket);
     this.client.OnDisconnect -= new EventHandler<SessionCloseEventArgs>(client_OnDisconnect);
     if (!Program.Shutdown)
     {
         // Try reconnect
         while (true)
         {
             try
             {
                 ConnectAndAssign(Settings.Instance.WorldServerIP, Settings.Instance.WorldServerPort);
                 break;
             }
             catch
             {
                 Log.WriteLine(LogLevel.Warn, "Trying to reconnect in 5 seconds.");
                 System.Threading.Thread.Sleep(5000);
             }
         }
         Log.WriteLine(LogLevel.Warn, "We should be up again :)");
     }
 }
示例#2
0
 void client_OnDisconnect(object sender, SessionCloseEventArgs e)
 {
     Log.WriteLine(LogLevel.Error, "Disconnected from server.");
     this.client.OnPacket -= new EventHandler<InterPacketReceivedEventArgs>(client_OnPacket);
     this.client.OnDisconnect -= new EventHandler<SessionCloseEventArgs>(client_OnDisconnect);
 }