Esempio n. 1
0
        private void onReceiveSocket()
        {
            while (true)
            {
                if (!_clientSocket.Connected)
                {
                    break;
                }

                try {
                    int receiveLength = _clientSocket.Receive(_result);

                    if (receiveLength > 0)
                    {
                        ByteBuffer buffer  = new ByteBuffer(_result);
                        int        command = buffer.ReadInt();
                        byte[]     data    = buffer.ReadBytes();
                        DebugManager.Log("服务器指令:" + command);

                        OnReceiveMessage(command, data);
                    }
                } catch (Exception e) {
                    DebugManager.Log(e.Message);
                }
            }
        }
Esempio n. 2
0
 static int ReadBytes(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         CFramework.ByteBuffer obj = (CFramework.ByteBuffer)ToLua.CheckObject <CFramework.ByteBuffer>(L, 1);
         byte[] o = obj.ReadBytes();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }