Ejemplo n.º 1
0
    static int SendMessage(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(NetworkPeerLua), typeof(string)))
            {
                NetworkPeerLua obj  = (NetworkPeerLua)ToLua.ToObject(L, 1);
                string         arg0 = ToLua.ToString(L, 2);
                obj.SendMessage(arg0);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(NetworkPeerLua), typeof(string), typeof(UnityEngine.SendMessageOptions)))
            {
                NetworkPeerLua obj  = (NetworkPeerLua)ToLua.ToObject(L, 1);
                string         arg0 = ToLua.ToString(L, 2);
                UnityEngine.SendMessageOptions arg1 = (UnityEngine.SendMessageOptions)ToLua.ToObject(L, 3);
                obj.SendMessage(arg0, arg1);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(NetworkPeerLua), typeof(string), typeof(PBStreamWriter)))
            {
                NetworkPeerLua obj  = (NetworkPeerLua)ToLua.ToObject(L, 1);
                string         arg0 = ToLua.ToString(L, 2);
                PBStreamWriter arg1 = (PBStreamWriter)ToLua.ToObject(L, 3);
                obj.SendMessage(arg0, arg1);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes(L, 1, typeof(NetworkPeerLua), typeof(string), typeof(object)))
            {
                NetworkPeerLua obj  = (NetworkPeerLua)ToLua.ToObject(L, 1);
                string         arg0 = ToLua.ToString(L, 2);
                object         arg1 = ToLua.ToVarObject(L, 3);
                obj.SendMessage(arg0, arg1);
                return(0);
            }
            else if (count == 4 && TypeChecker.CheckTypes(L, 1, typeof(NetworkPeerLua), typeof(string), typeof(object), typeof(UnityEngine.SendMessageOptions)))
            {
                NetworkPeerLua obj  = (NetworkPeerLua)ToLua.ToObject(L, 1);
                string         arg0 = ToLua.ToString(L, 2);
                object         arg1 = ToLua.ToVarObject(L, 3);
                UnityEngine.SendMessageOptions arg2 = (UnityEngine.SendMessageOptions)ToLua.ToObject(L, 4);
                obj.SendMessage(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: NetworkPeerLua.SendMessage"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 2
0
 public static void NetworkDecodeRecv(NetworkPeerLua peer, string msgName, MemoryStream stream, LuaFunction func)
 {
     if (_decodeRecvMethod != null)
     {
         if (stream == null)
         {
             _decodeRecvMethod.Call(peer, msgName, null, func);
         }
         else
         {
             _decodeRecvMethod.Call(peer, msgName, new PBStreamReader(stream.ToArray()), func);
         }
     }
 }
Ejemplo n.º 3
0
 static int RegisterMessage(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         NetworkPeerLua obj  = (NetworkPeerLua)ToLua.CheckObject(L, 1, typeof(NetworkPeerLua));
         string         arg0 = ToLua.CheckString(L, 2);
         LuaFunction    arg1 = ToLua.CheckLuaFunction(L, 3);
         obj.RegisterMessage(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 4
0
 static int Get(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         PeerManagerLua obj  = (PeerManagerLua)ToLua.CheckObject(L, 1, typeof(PeerManagerLua));
         string         arg0 = ToLua.CheckString(L, 2);
         NetworkPeerLua o    = obj.Get(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }