Exemplo n.º 1
0
 static int GetBodySize(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         Protocols.Protocol obj = (Protocols.Protocol)ToLua.CheckObject <Protocols.Protocol>(L, 1);
         uint o = obj.GetBodySize();
         LuaDLL.lua_pushnumber(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemplo n.º 2
0
        public Protocol GetMessage(int sessionId)
        {
            Protocol proto = allSessions[sessionId].GetMessage();

            if (proto != null)
            {
                if (proto.GetID() == ProtoIDReserve.CMD_SERVER_CONNECTED)
                {
                    ServerConnected body = (ServerConnected)proto.GetBody();
                    if (body.success)
                    {
                        Debug.Log("[{0}]CONNECTED", sessionId);
                    }
                    else
                    {
                        Debug.Log("[{0}]CONNECT FAILED", sessionId);
                    }
                }
                else if (proto.GetID() == ProtoIDReserve.CMD_SERVER_DISCONNECTED)
                {
                    Debug.Log("[{0}]DISCONNECTED", sessionId);
                }
                else
                {
                    Debug.Log("[{0}][RECV]{1}({2} bytes) {3}", sessionId, proto.GetID().ToString(), proto.GetBodySize().ToString(), DateTime.Now.ToString("HH:mm:ss.fff"));
                }
            }
            else
            {
                Debug.Log("[{0}]No Message", sessionId);
            }

            return(proto);
        }