void _init(NetworkInterface networkInterface)
		{
			_networkInterface = networkInterface;
			_buffer = new byte[KBEngineApp.app.getInitArgs().RECV_BUFFER_MAX];
			
			messageReader = new MessageReader();
		}
		void _init(NetworkInterface networkInterface)
		{
			_networkInterface = networkInterface;
			
			_buffer = new byte[KBEngineApp.app.getInitArgs().SEND_BUFFER_MAX];
			
			_wpos = 0; 
			_spos = 0;
			_sending = 0;
		}
Ejemplo n.º 3
0
        public KBEngineApp()
        {
            app = this;
            networkInterface_ = new NetworkInterface(this);
            kbethread = new KBEThread(this);
            t_ = new Thread(new ThreadStart(kbethread.run));
            t_.Start();

            // 注册事件
            installEvents();
        }
Ejemplo n.º 4
0
        public KBEngineApp()
        {
            app = this;

            loginappIP = ip;
            loginappPort = port;

            networkInterface_ = new NetworkInterface(this);
            kbethread_ = new KBEThread(this);
            t_ = new Thread(new ThreadStart(kbethread_.run));
            t_.Start();
        }
Ejemplo n.º 5
0
        public void send(NetworkInterface networkInterface)
        {
            fini(true);

            for(int i=0; i<streamList.Count; i++)
            {
                stream = streamList[i];
                networkInterface.send(stream.getbuffer());
            }

            streamList.Clear();
            stream = new MemoryStream();
        }
Ejemplo n.º 6
0
 static int close(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         KBEngine.NetworkInterface obj = (KBEngine.NetworkInterface)ToLua.CheckObject <KBEngine.NetworkInterface>(L, 1);
         obj.close();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 7
0
 static int packetReceiver(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         KBEngine.NetworkInterface obj = (KBEngine.NetworkInterface)ToLua.CheckObject <KBEngine.NetworkInterface>(L, 1);
         KBEngine.PacketReceiver   o   = obj.packetReceiver();
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 8
0
 static int sock(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         KBEngine.NetworkInterface obj = (KBEngine.NetworkInterface)ToLua.CheckObject <KBEngine.NetworkInterface>(L, 1);
         System.Net.Sockets.Socket o   = obj.sock();
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 9
0
 static int valid(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         KBEngine.NetworkInterface obj = (KBEngine.NetworkInterface)ToLua.CheckObject <KBEngine.NetworkInterface>(L, 1);
         bool o = obj.valid();
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 10
0
 static int _onConnectionState(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         KBEngine.NetworkInterface obj = (KBEngine.NetworkInterface)ToLua.CheckObject <KBEngine.NetworkInterface>(L, 1);
         KBEngine.NetworkInterface.ConnectState arg0 = (KBEngine.NetworkInterface.ConnectState)ToLua.CheckObject <KBEngine.NetworkInterface.ConnectState>(L, 2);
         obj._onConnectionState(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 11
0
 static int send(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         KBEngine.NetworkInterface obj  = (KBEngine.NetworkInterface)ToLua.CheckObject <KBEngine.NetworkInterface>(L, 1);
         KBEngine.MemoryStream     arg0 = (KBEngine.MemoryStream)ToLua.CheckObject <KBEngine.MemoryStream>(L, 2);
         bool o = obj.send(arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 12
0
 static int connectTo(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 5);
         KBEngine.NetworkInterface obj = (KBEngine.NetworkInterface)ToLua.CheckObject <KBEngine.NetworkInterface>(L, 1);
         string arg0 = ToLua.CheckString(L, 2);
         int    arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         KBEngine.NetworkInterface.ConnectCallback arg2 = (KBEngine.NetworkInterface.ConnectCallback)ToLua.CheckDelegate <KBEngine.NetworkInterface.ConnectCallback>(L, 4);
         object arg3 = ToLua.ToVarObject(L, 5);
         obj.connectTo(arg0, arg1, arg2, arg3);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 13
0
        public void send(NetworkInterface networkInterface)
        {
            fini(true);

            if(networkInterface.valid())
            {
                for(int i=0; i<streamList.Count; i++)
                {
                    stream = streamList[i];
                    networkInterface.send(stream.getbuffer());
                }
            }
            else
            {
                Dbg.ERROR_MSG("Bundle::send: networkInterface invalid!");
            }

            streamList.Clear();
            stream.clear();
        }
Ejemplo n.º 14
0
    static int _CreateKBEngine_NetworkInterface(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                KBEngine.NetworkInterface obj = new KBEngine.NetworkInterface();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: KBEngine.NetworkInterface.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 15
0
        public virtual void reset()
        {
            KBEngine.Event.clearFiredEvents();

            clearEntities(true);

            currserver = "";
            currstate = "";
            _serverdatas = new byte[0];
            serverVersion = "";
            serverScriptVersion = "";

            entity_uuid = 0;
            entity_id = 0;
            entity_type = "";

            _entityIDAliasIDList.Clear();
            _bufferedCreateEntityMessage.Clear();

            _lastticktime = System.DateTime.Now;
            _lastUpdateToServerTime = System.DateTime.Now;

            spaceID = 0;
            spaceResPath = "";
            isLoadedGeometry = false;

            _networkInterface.reset();
            _networkInterface = new NetworkInterface();

            _spacedatas.Clear();
        }
Ejemplo n.º 16
0
        /*
            登录到服务端,登录到网关(baseapp)
        */
        public void login_baseapp(bool noconnect)
        {
            if(noconnect)
            {
                Event.fireOut("onLoginBaseapp", new object[]{});

                _networkInterface.reset();
                _networkInterface = new NetworkInterface();
                _networkInterface.connectTo(baseappIP, baseappPort, onConnectTo_baseapp_callback, null);
            }
            else
            {
                Bundle bundle = new Bundle();
                bundle.newMessage(Message.messages["Baseapp_loginBaseapp"]);
                bundle.writeString(username);
                bundle.writeString(password);
                bundle.send(_networkInterface);
            }
        }
Ejemplo n.º 17
0
 public PacketReceiver(NetworkInterface networkInterface)
 {
     _init(networkInterface);
 }
 public PacketReceiver(NetworkInterface networkInterface)
 {
 	_init(networkInterface);
 }
        void _init(NetworkInterface networkInterface)
        {
            _networkInterface = networkInterface;

            _buffer = new byte[KBEngineApp.app.getInitArgs().SEND_BUFFER_MAX];
            _asyncSendMethod = new AsyncSendMethod(this._asyncSend);
            _asyncCallback = new AsyncCallback(_onSent);

            _wpos = 0;
            _spos = 0;
            _sending = 0;
        }
Ejemplo n.º 20
0
 public void _closeNetwork(NetworkInterface networkInterface)
 {
     networkInterface.close();
 }
Ejemplo n.º 21
0
 void _init(NetworkInterface networkInterface)
 {
     _networkInterface = networkInterface;
     _buffer = new byte[NetworkInterface.RECV_BUFFER_MAX];
     _asyncCallback = new AsyncCallback(_onRecv);
 }
Ejemplo n.º 22
0
 public Mailbox()
 {
     networkInterface_ = KBEngineApp.app.networkInterface();
 }
Ejemplo n.º 23
0
 void initNetwork()
 {
     Message.bindFixedMessage();
     _networkInterface = new NetworkInterface();
 }
Ejemplo n.º 24
0
        void _init(NetworkInterface networkInterface)
        {
            _networkInterface = networkInterface;

            _buffer = new byte[NetworkInterface.SEND_BUFFER_MAX];
            _asyncCallback = new AsyncCallback(_onSent);

            _wpos = 0;
            _spos = 0;
            _sending = 0;
        }
        int _wpos = 0; // 写入的数据位置

        #endregion Fields

        #region Constructors

        public PacketSender(NetworkInterface networkInterface)
        {
            _init(networkInterface);
        }
Ejemplo n.º 26
0
		public Mailbox()
		{
			networkInterface_ = KBEngineApp.app.networkInterface();
		}