Beispiel #1
0
        private void _ProcTerminateEvent(LPNetEvent netEvent)
        {
            LPSocker            socker         = null;
            LPConnector         connector      = null;
            LPTerminateNetEvent terminateEvent = null;

            if (LOG_ERROR(netEvent != null))
            {
                goto Exit0;
            }

            terminateEvent = (LPTerminateNetEvent)netEvent;
            socker         = terminateEvent.Socker;
            if (!socker.IsAcceptCreate)
            {
                connector = (LPConnector)socker.Parent;
                m_NetMessageHandler.OnConnectDisconnected(socker, connector);
            }
            else
            {
                m_NetMessageHandler.OnDisconnected(socker);
            }

            socker.OnClose();

Exit0:
            return;
        }
Beispiel #2
0
        public void OnConnect(IAsyncResult ar)
        {
            bool         result       = false;
            LPSocker     socker       = null;
            LPConnector  connector    = null;
            HandlerParam handlerParam = null;

            try
            {
                if (LOG_ERROR(ar != null))
                {
                    goto Exit0;
                }

                handlerParam = (HandlerParam)ar.AsyncState;
                if (LOG_ERROR(handlerParam != null))
                {
                    goto Exit0;
                }

                if (LOG_ERROR(handlerParam.HandlerType == EHandlerType.Connector))
                {
                    goto Exit0;
                }
                connector = (LPConnector)handlerParam.Handler;

                LP.Logger.IMP("connect success.");

                connector.Client.EndConnect(ar);

                socker = LP.NetModule.CreateSocker(connector.Client.Client, connector.PacketParser, connector, false);
                if (LOG_ERROR(socker != null))
                {
                    goto Exit0;
                }

                result = LP.NetModule.EventMgr.PushEstablishEvent(socker);
                if (LOG_ERROR(result))
                {
                    goto Exit0;
                }
            }
            catch (SocketException e)
            {
                //if(!connector.IsStoped)
                {
                    LP.Logger.P_ERR("ErrorCode={0},SocketErrorCode={1}, Message:{2}, StackTrace:{3}",
                                    e.ErrorCode, e.SocketErrorCode, e.Message, e.StackTrace);

                    LP.NetModule.EventMgr.PushConnectorErrorEvent(connector, e.ErrorCode);
                }
            }
            catch (Exception e)
            {
                LPMiniDump.GenerateNormalDump(e);
            }

Exit0:
            return;
        }
Beispiel #3
0
        public LPConnector CreateConnector(ILPPacketParser packetParser)
        {
            TcpClient   tc        = null;
            LPConnector connector = null;

            if (LOG_ERROR(packetParser != null))
            {
                goto Exit0;
            }

            connector = new LPConnector();
            if (LOG_ERROR(connector != null))
            {
                goto Exit0;
            }

            tc = new TcpClient();
            if (LOG_ERROR(tc != null))
            {
                goto Exit0;
            }

            connector.Client       = tc;
            connector.ID           = _GenerateConnectorID();
            connector.PacketParser = packetParser;

            return(connector);

Exit0:
            return(null);
        }
Beispiel #4
0
        internal bool PushConnectorErrorEvent(LPConnector connector, int errorNo)
        {
            bool result = false;
            LPConnectErrorNetEvent connectErrorEvent = null;

            if (LOG_ERROR(connector != null))
            {
                goto Exit0;
            }


            connectErrorEvent = (LPConnectErrorNetEvent)_CreateEvent(ENetEventType.ConnectError);
            if (LOG_ERROR(connectErrorEvent != null))
            {
                goto Exit0;
            }


            connectErrorEvent.Flag      = connector.ID;
            connectErrorEvent.Connector = connector;
            connectErrorEvent.ErrorNo   = errorNo;

            lock (m_EventListLocker[connectErrorEvent.Flag % m_EventListCount])
            {
                result = m_EventLists[connectErrorEvent.Flag % m_EventListCount].PushRear(connectErrorEvent);
                if (LOG_ERROR(result))
                {
                    goto Exit0;
                }
            }

            return(true);

Exit0:
            return(false);
        }
 public void OnConnectDisconnected(LPSocker socker, LPConnector connector)
 {
     LP.Logger.IMP("OnConnectDisconnected output : socker id is {0}, connector id is {1}", socker.ID, connector.ID);
 }
 public void OnConnectError(LPConnector connector, int errorNo)
 {
     LP.Logger.IMP("OnConnectError output : connector id is {0}, error no is {1}", connector.ID, errorNo);
 }