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

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

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

            KBELuaUtil.CallMethod("Event", "Brocast", new object[] { "onConnectionState", success });

            if (state.connectCB != null)
            {
                state.connectCB(state.connectIP, state.connectPort, success, state.userData);
            }
        }
        public void process()
        {
            int t_wpos = Interlocked.Add(ref _wpos, 0);

            if (_rpos < t_wpos)
            {
                KBELuaUtil.CallMethod("KBEngineLua.MessageReader", "process", new object[] { _buffer, (UInt32)_rpos, (UInt32)(t_wpos - _rpos) });
                Interlocked.Exchange(ref _rpos, t_wpos);
            }
            else if (t_wpos < _rpos)
            {
                KBELuaUtil.CallMethod("KBEngineLua.MessageReader", "process", new object[] { _buffer, (UInt32)_rpos, (UInt32)(_buffer.Length - _rpos) });
                KBELuaUtil.CallMethod("KBEngineLua.MessageReader", "process", new object[] { _buffer, (UInt32)0, (UInt32)t_wpos });
                Interlocked.Exchange(ref _rpos, t_wpos);
            }
            else
            {
                // 没有可读数据
            }
        }