Ejemplo n.º 1
0
        public void Reconnect()
        {
            lock (lockRestartObject)
            {
                if (this.IsReconnecting)
                {
                    LogManager.InfoWithCallback(string.Format("->当前网络已经在重拨,请等待…………"));
                    return;
                }

                if (!this.HttperParamsItem.IsSupportedReconnect)
                {
                    LogManager.InfoWithCallback(string.Format("-> 当前没有设置网络重联功能,请检查!"));
                    this.Stop();
                    return;
                }

                SoundPlayer.PlayAlter();
                ThreadPool.QueueUserWorkItem(new WaitCallback(delegate(object obj)
                {
                    if (Interlocked.Increment(ref lockCount) > 1)
                    {
                        LogManager.InfoWithCallback(string.Format("->当前网络已经在重拨,当前网络重拨计数:{0}", lockCount));
                        return;
                    }

                    this.PauseProcess();
                    this.OnReconnectChanged(true);
                    LogManager.InfoWithCallback(string.Format("-> 游戏网站:{0} 开始拒绝查询,正在进行网络重连,请稍等............",
                                                              this.HttperParamsItem.CurrentGameServer.Header));
                    //AutoResetEvent reconnectEvent = null;
                    try
                    {
                        //reconnectEvent = new AutoResetEvent(false);
                        //bool isAllReconnect = MultiGameNetManager.CheckAll(this, reconnectEvent);
                        //if (!isAllReconnect && (null != reconnectEvent))
                        //{
                        //    reconnectEvent.WaitOne();
                        //}
                        //else
                        //{
                        ReconnectManager.Instance.ResetLogManager(GameLogManager.Instance);
                        MultiGameNetManager.Reconnect(this.HttperParamsItem);
                        //}

                        //if (null != reconnectEvent)
                        //{
                        //    reconnectEvent.Close();
                        //}
                    }
                    catch (Exception ex)
                    {
                        this.LogManager.Error(string.Format("reconnectEvent close error:{0}", ex.Message));
                    }
                    finally
                    {
                        //Interlocked.Decrement(ref lockCount);
                        Interlocked.Exchange(ref lockCount, 0);
                    }

                    if (MultiGameNetManager.IsConnected)
                    {
                        if (this.IsFinished || this.isDisposed)
                        {
                            return;
                        }
                        LogManager.InfoWithCallback(string.Format("-> 网络重连完成,等待程序就绪!"));
                        this.RestartProcess();
                        LogManager.InfoWithCallback(string.Format("-> 程序就绪,正在重新启动查询功能,请稍等..........."));
                    }
                    else
                    {
                        LogManager.InfoWithCallback(string.Format("-> 网络重连失败,请检查原因!"));
                        this.Stop();
                    }
                    SoundPlayer.StopWarn();
                    this.OnReconnectChanged(false);
                }));
            }
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     MultiGameNetManager.UnRegister(this);
     OnDispose();
     isDisposed = true;
 }
Ejemplo n.º 3
0
 public HttperManagerBase(LogManagerBase logManager)
 {
     this.LogManager = logManager;
     MultiGameNetManager.Register(this);
 }