Example #1
0
        public override void OnConnectionEvent(object sender, SocketConnectionEvent e)
        {
            base.OnConnectionEvent(sender, e);
            switch (e)
            {
            case SocketConnectionEvent.Disconnected:
                if (Program.GameEngine != null)
                {
                    Program.GameEngine.IsConnected = false;
                }
                Program.GameMess.Warning("You have been disconnected from server.");
                break;

            case SocketConnectionEvent.Connected:
                if (Program.GameEngine != null)
                {
                    Program.GameEngine.IsConnected = true;
                }
                break;

            case SocketConnectionEvent.Reconnected:
                if (Program.GameEngine != null)
                {
                    Program.GameEngine.IsConnected = true;
                    Program.GameEngine.Resume();
                }
                Program.GameMess.System("You have reconnected");

                break;

            default:
                throw new ArgumentOutOfRangeException("e");
            }
        }
Example #2
0
        public override void OnConnectionEvent(object sender, SocketConnectionEvent e)
        {
            base.OnConnectionEvent(sender, e);
            switch (e)
            {
                case SocketConnectionEvent.Disconnected:
                    if (Program.GameEngine != null)
                        Program.GameEngine.IsConnected = false;
                    Program.GameMess.Warning("You have been disconnected from server.");
                    break;
                case SocketConnectionEvent.Connected:
                    if (Program.GameEngine != null)
                        Program.GameEngine.IsConnected = true;
                    break;
                case SocketConnectionEvent.Reconnected:
                    if (Program.GameEngine != null)
                    {
                        Program.GameEngine.IsConnected = true;
                        Program.GameEngine.Resume();
                    }
                        Program.GameMess.System("You have reconnected");

                    break;
                default:
                    throw new ArgumentOutOfRangeException("e");
            }
        }
Example #3
0
        public override void OnConnectionEvent(object sender, SocketConnectionEvent e)
        {
            base.OnConnectionEvent(sender, e);
            switch (e)
            {
            case SocketConnectionEvent.Disconnected:
                if (Program.GameEngine != null)
                {
                    Program.GameEngine.IsConnected = false;
                }
                if (Program.Dispatcher != null)
                {
                    Program.Dispatcher.Invoke(new Action <string>(Program.TraceWarning),
                                              "You have been disconnected from server.");
                }
                else
                {
                    Program.TraceWarning("You have been disconnected from server.");
                }
                break;

            case SocketConnectionEvent.Connected:
                if (Program.GameEngine != null)
                {
                    Program.GameEngine.IsConnected = true;
                }
                break;

            case SocketConnectionEvent.Reconnected:
                if (Program.GameEngine != null)
                {
                    Program.GameEngine.IsConnected = true;
                    Program.GameEngine.Resume();
                }
                if (Program.Dispatcher != null)
                {
                    Program.Dispatcher.Invoke(
                        new Action(
                            () =>
                            Program.Trace.TraceEvent(
                                TraceEventType.Information,
                                EventIds.Event,
                                "You have reconnected")));
                }
                else
                {
                    Program.Trace.TraceEvent(TraceEventType.Information, EventIds.Event, "You have reconnected");
                }

                break;

            default:
                throw new ArgumentOutOfRangeException("e");
            }
        }
Example #4
0
 internal void CallOnConnectionEvent(SocketConnectionEvent args)
 {
     try
     {
         Log.DebugFormat("CallOnConnectionEvent {0}", args);
         this.OnConnectionEvent(this, args);
     }
     catch (Exception e)
     {
         Log.Error("CallOnConnectionEvent Error", e);
     }
 }
Example #5
0
 internal void CallOnConnectionEvent(SocketConnectionEvent args)
 {
     try
     {
         Log.DebugFormat("CallOnConnectionEvent {0}", args);
         this.OnConnectionEvent(this, args);
         this.ConnectionChanged?.Invoke(this, new ConnectionChangedEventArgs {
             Event = args
         });
     }
     catch (Exception e)
     {
         Log.Error("CallOnConnectionEvent Error", e);
     }
 }
Example #6
0
 public override void OnConnectionEvent(object sender, SocketConnectionEvent e)
 {
     Log.DebugFormat("OnConnectionEvent {0}",e);
     if (e == SocketConnectionEvent.Disconnected && !this.ForcedDisconnect)
     {
         Task.Factory.StartNew(this.DoReconnect);
         return;
     }
     if (e != SocketConnectionEvent.Disconnected)
     {
         this.RetryCount = 0;
         this.Reconnecting = false;
         this.ForcedDisconnect = false;
     }
 }
Example #7
0
 public override void OnConnectionEvent(object sender, SocketConnectionEvent e)
 {
     Log.DebugFormat("OnConnectionEvent {0}", e);
     if (e == SocketConnectionEvent.Disconnected && !this.ForcedDisconnect)
     {
         Task.Factory.StartNew(this.DoReconnect);
         return;
     }
     if (e != SocketConnectionEvent.Disconnected)
     {
         this.RetryCount       = 0;
         this.Reconnecting     = false;
         this.ForcedDisconnect = false;
     }
 }
Example #8
0
 public override void OnConnectionEvent(object sender, SocketConnectionEvent e)
 {
     Log.DebugFormat("ConnectionEvent {0} {1}", this.EndPoint, e);
     switch (e)
     {
         case SocketConnectionEvent.Disconnected:
             //var c = State.Instance.GetClient(this.Client);
             //if (c != null)
             //    c.OnDisconnect(true);
             break;
         case SocketConnectionEvent.Connected:
             break;
         case SocketConnectionEvent.Reconnected:
             break;
     }
 }
Example #9
0
        public override void OnConnectionEvent(object sender, SocketConnectionEvent e)
        {
            Log.DebugFormat("ConnectionEvent {0} {1}", this.EndPoint, e);
            switch (e)
            {
            case SocketConnectionEvent.Disconnected:
                //var c = State.Instance.GetClient(this.Client);
                //if (c != null)
                //    c.OnDisconnect(true);
                break;

            case SocketConnectionEvent.Connected:
                break;

            case SocketConnectionEvent.Reconnected:
                break;
            }
        }
Example #10
0
 public override void OnConnectionEvent(object sender, SocketConnectionEvent e)
 {
     Log.DebugFormat("OnConnectionEvent {0}", e);
     if (e == SocketConnectionEvent.Disconnected && !this.ForcedDisconnect)
     {
         if (_reportedDisconnect == false)
         {
             _reportedDisconnect = true;
             Log.ErrorFormat("Disconnect Event {0}", this.EndPoint);
         }
         Task.Factory.StartNew(this.DoReconnect);
         return;
     }
     if (e != SocketConnectionEvent.Disconnected)
     {
         this.RetryCount          = 0;
         this.Reconnecting        = false;
         this.ForcedDisconnect    = false;
         this._reportedDisconnect = false;
     }
 }
 public override void OnConnectionEvent(object sender, SocketConnectionEvent e)
 {
     Log.DebugFormat("OnConnectionEvent {0}", e);
     if (e == SocketConnectionEvent.Disconnected && !this.ForcedDisconnect)
     {
         if (_reportedDisconnect == false)
         {
             _reportedDisconnect = true;
             Log.ErrorFormat("Disconnect Event {0}",this.EndPoint);
         }
         Task.Factory.StartNew(this.DoReconnect);
         return;
     }
     if (e != SocketConnectionEvent.Disconnected)
     {
         this.RetryCount = 0;
         this.Reconnecting = false;
         this.ForcedDisconnect = false;
         this._reportedDisconnect = false;
     }
 }
Example #12
0
        public override void OnConnectionEvent(object sender, SocketConnectionEvent e)
        {
            base.OnConnectionEvent(sender, e);
            switch (e)
            {
                case SocketConnectionEvent.Disconnected:
                    if (Program.GameEngine != null)
                        Program.GameEngine.IsConnected = false;
                    if (Program.Dispatcher != null)
                        Program.Dispatcher.Invoke(new Action<string>(Program.TraceWarning),
                                                  "You have been disconnected from server.");
                    else
                        Program.TraceWarning("You have been disconnected from server.");
                    break;
                case SocketConnectionEvent.Connected:
                    if (Program.GameEngine != null)
                        Program.GameEngine.IsConnected = true;
                    break;
                case SocketConnectionEvent.Reconnected:
                    if (Program.GameEngine != null)
                    {
                        Program.GameEngine.IsConnected = true;
                        Program.GameEngine.Resume();
                    }
                    if (Program.Dispatcher != null)
                        Program.Dispatcher.Invoke(
                            new Action(
                                () =>
                                    Program.Trace.TraceEvent(
                                        TraceEventType.Information,
                                        EventIds.Event,
                                        "You have reconnected")));
                    else
                        Program.Trace.TraceEvent(TraceEventType.Information, EventIds.Event, "You have reconnected");

                    break;
                default:
                    throw new ArgumentOutOfRangeException("e");
            }
        }
Example #13
0
    // 每帧检查处理消息
    public void UpdateSocket()
    {
        // 向 Lua 发送缓存的socket链接状态
        if (cacheConnectEvent != SocketConnectionEvent.None)
        {
            Debug.Log(cacheConnectEvent.ToString());

            LuaUtils.PostLuaEvent(cacheConnectEvent.ToString(), null);
            cacheConnectEvent = SocketConnectionEvent.None;
        }
        // 检查是否有消息来了
        if (null != _conn && _conn.State == SocketConnectionState.Connected)
        {
            List <SocketData> sockDatas = _conn.RecvSocketDataList();

            if (sockDatas != null && sockDatas.Count > 0)
            {
                for (int i = 0; i < sockDatas.Count; ++i)
                {
                    SocketData data    = sockDatas [i];
                    ReceiveMsg msgData = new ReceiveMsg();
                    msgData.data = data;

                    tobeHandledSocketData.Enqueue(msgData);
                }
            }
        }
        // 处理接收的消息
        if (tobeHandledSocketData.Count > 0)
        {
            ReceiveMsg msgData = tobeHandledSocketData.Dequeue();
            DealWithSocketData(msgData);
        }
        else
        {
        }
    }
Example #14
0
 internal void CallOnConnectionEvent(SocketConnectionEvent args)
 {
     try
     {
         Log.DebugFormat("CallOnConnectionEvent {0}", args);
         this.OnConnectionEvent(this, args);
     }
     catch (Exception e)
     {
         Log.Error("CallOnConnectionEvent Error", e);
     }
 }
Example #15
0
 public abstract void OnConnectionEvent(object sender, SocketConnectionEvent e);
Example #16
0
 private void OnConnectSuccessEvent(object sender, EventArgs e)
 {
     cacheConnectEvent = SocketConnectionEvent.ConnectSuccess;
 }
Example #17
0
 private void OnConnectLostEvent(object sender, EventArgs e)
 {
     cacheConnectEvent = SocketConnectionEvent.ConnectLost;
 }
Example #18
0
 public virtual void OnConnectionEvent(object sender, SocketConnectionEvent e)
 {
 }
Example #19
0
 public abstract void OnConnectionEvent(object sender, SocketConnectionEvent e);