public void _onConnectionState(ConnectState state)
        {
            KBEngine.Event.deregisterIn(this);

            bool success = (state.error == "" && valid());

            if (success)
            {
                Dbg.DEBUG_MSG(string.Format("NetworkInterfaceBase::_onConnectionState(), connect to {0} is success!", state.socket.RemoteEndPoint.ToString()));
                _packetReceiver = createPacketReceiver();
                _packetReceiver.startRecv();
                connected = true;
            }
            else
            {
                reset();
                Dbg.ERROR_MSG(string.Format("NetworkInterfaceBase::_onConnectionState(), connect error! ip: {0}:{1}, err: {2}", state.connectIP, state.connectPort, state.error));
            }

            Event.fireAll("onConnectionState", new object[] { success });

            if (state.connectCB != null)
            {
                state.connectCB(state.connectIP, state.connectPort, success, state.userData);
            }
        }
示例#2
0
        public void _onConnectStatus(ConnectState state)
        {
            KBEngine.Event.deregisterIn(this);

            bool success = (state.error == "" && valid());

            if (success)
            {
                Dbg.DEBUG_MSG(string.Format("NetworkInterface::_onConnectStatus(), connect to {0} is success!", state.socket.RemoteEndPoint.ToString()));
                _packetReceiver = new PacketReceiver(this);
                _packetReceiver.startRecv();
            }
            else
            {
                Dbg.ERROR_MSG(string.Format("NetworkInterface::_onConnectStatus(), connect is error! ip: {0}:{1}, err: {2}", state.connectIP, state.connectPort, state.error));
            }

            LuaFramework.Util.CallMethod("Event", "Brocast", new object[] { "onConnectStatus", success });
            //Event.fireOut("onConnectStatus", new object[]{success});

            if (state.connectCB != null)
            {
                state.connectCB(state.connectIP, state.connectPort, success, state.userData);
            }
        }
        public void _onConnectStatus(ConnectState state)
        {
            KBEngine.Event.deregisterIn(this);

            bool success = (state.error == "" && valid());
            if(success)
            {
                Dbg.DEBUG_MSG(string.Format("NetworkInterface::_onConnectStatus(), connect to {0} is success!", state.socket.RemoteEndPoint.ToString()));
                _packetReceiver = new PacketReceiver(this);
                _packetReceiver.startRecv();
            }
            else
            {
                Dbg.ERROR_MSG(string.Format("NetworkInterface::_onConnectStatus(), connect is error! ip: {0}:{1}, err: {2}", state.connectIP, state.connectPort, state.error));
            }

            Event.fireOut("onConnectStatus", new object[]{success});

            if (state.connectCB != null)
                state.connectCB(state.connectIP, state.connectPort, success, state.userData);
        }