static int Close(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         ShibaInu.UdpSocket obj = (ShibaInu.UdpSocket)ToLua.CheckObject <ShibaInu.UdpSocket>(L, 1);
         obj.Close();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int Send(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         ShibaInu.UdpSocket obj  = (ShibaInu.UdpSocket)ToLua.CheckObject <ShibaInu.UdpSocket>(L, 1);
         object             arg0 = ToLua.ToVarObject(L, 2);
         obj.Send(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int set_msgProtocol(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            ShibaInu.UdpSocket    obj  = (ShibaInu.UdpSocket)o;
            ShibaInu.IMsgProtocol arg0 = (ShibaInu.IMsgProtocol)ToLua.CheckObject <ShibaInu.IMsgProtocol>(L, 2);
            obj.msgProtocol = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index msgProtocol on a nil value"));
        }
    }
 static int Connect(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 4);
         ShibaInu.UdpSocket obj  = (ShibaInu.UdpSocket)ToLua.CheckObject <ShibaInu.UdpSocket>(L, 1);
         string             arg0 = ToLua.CheckString(L, 2);
         int  arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         uint arg2 = (uint)LuaDLL.luaL_checknumber(L, 4);
         obj.Connect(arg0, arg1, arg2);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int get_connected(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            ShibaInu.UdpSocket obj = (ShibaInu.UdpSocket)o;
            bool ret = obj.connected;
            LuaDLL.lua_pushboolean(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index connected on a nil value"));
        }
    }
    static int set_callback(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            ShibaInu.UdpSocket             obj  = (ShibaInu.UdpSocket)o;
            System.Action <string, object> arg0 = (System.Action <string, object>)ToLua.CheckDelegate <System.Action <string, object> >(L, 2);
            obj.callback = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index callback on a nil value"));
        }
    }
    static int set_luaTarget(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            ShibaInu.UdpSocket obj  = (ShibaInu.UdpSocket)o;
            LuaTable           arg0 = ToLua.CheckLuaTable(L, 2);
            obj.luaTarget = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index luaTarget on a nil value"));
        }
    }
    static int get_host(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            ShibaInu.UdpSocket obj = (ShibaInu.UdpSocket)o;
            string             ret = obj.host;
            LuaDLL.lua_pushstring(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index host on a nil value"));
        }
    }
    static int get_port(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            ShibaInu.UdpSocket obj = (ShibaInu.UdpSocket)o;
            int ret = obj.port;
            LuaDLL.lua_pushinteger(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index port on a nil value"));
        }
    }
Ejemplo n.º 10
0
    static int get_msgProtocol(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            ShibaInu.UdpSocket    obj = (ShibaInu.UdpSocket)o;
            ShibaInu.IMsgProtocol ret = obj.msgProtocol;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index msgProtocol on a nil value"));
        }
    }
Ejemplo n.º 11
0
    static int get_callback(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            ShibaInu.UdpSocket             obj = (ShibaInu.UdpSocket)o;
            System.Action <string, object> ret = obj.callback;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index callback on a nil value"));
        }
    }
Ejemplo n.º 12
0
    static int get_luaTarget(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            ShibaInu.UdpSocket    obj = (ShibaInu.UdpSocket)o;
            LuaInterface.LuaTable ret = obj.luaTarget;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index luaTarget on a nil value"));
        }
    }
Ejemplo n.º 13
0
    static int _CreateShibaInu_UdpSocket(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                ShibaInu.UdpSocket obj = new ShibaInu.UdpSocket();
                ToLua.PushObject(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: ShibaInu.UdpSocket.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 14
0
        void Update()
        {
            TimeUtil.Update();
            Timer.Update();
            UdpSocket.Update();


            // 执行需要在主线程运行的 Action
            lock (LOCK_OBJECT) {
                if (m_threadActions.Count > 0)
                {
                    m_tempActions.AddRange(m_threadActions);
                    m_threadActions.Clear();
                }
            }
            if (m_tempActions.Count > 0)
            {
                foreach (Action action in m_tempActions)
                {
                    try {
                        action();
                    } catch (Exception e) {
                        Logger.LogException(e);
                    }
                }
                m_tempActions.Clear();
            }


            // 执行网络相关回调
            lock (LOCK_OBJECT) {
                if (m_netActions.Count > 0)
                {
                    m_tempActions.AddRange(m_netActions);
                    m_netActions.Clear();
                }
            }
            if (m_tempActions.Count > 0)
            {
                foreach (Action action in m_tempActions)
                {
                    try {
                        action();
                    } catch (Exception e) {
                        Logger.LogException(e);
                    }
                }
                m_tempActions.Clear();
            }


            // 屏幕尺寸有改变
            if (Screen.width != m_screenSize.x || Screen.height != m_screenSize.y)
            {
                m_screenSize.Set(Screen.width, Screen.height);
                List <Action> removes = new List <Action> ();
                foreach (Action handler in resizeHandler)
                {
                    try {
                        handler();
                    } catch (Exception e) {
                        removes.Add(handler);
                        Logger.LogException(e);
                    }
                }
                // 移除执行时报错的 action
                foreach (Action handler in removes)
                {
                    resizeHandler.Remove(handler);
                }

                // lua Resize
                m_luaLoopHandler.BeginPCall();
                m_luaLoopHandler.Push(EVENT_RESIZE);
                m_luaLoopHandler.Push(TimeUtil.timeSec);
                m_luaLoopHandler.PCall();
                m_luaLoopHandler.EndPCall();
            }

            StageTouchEventDispatcher.Update();

            // lua Update
            m_luaLoopHandler.BeginPCall();
            m_luaLoopHandler.Push(EVENT_UPDATE);
            m_luaLoopHandler.Push(TimeUtil.timeSec);
            m_luaLoopHandler.PCall();
            m_luaLoopHandler.EndPCall();
        }
Ejemplo n.º 15
0
        void Update()
        {
#if UNITY_EDITOR
            // Unity2018 FrameDebugger 窗口会更新内容,导致无法查看数据
            if (UnityEditor.EditorApplication.isPaused)
            {
                return;
            }
#endif

            TimeUtil.Update();
            Timer.Update();
            UdpSocket.Update();
            NetHelper.Update();


            lock (LOCK_OBJECT)
            {
                // 需要在主线程运行的 Action
                if (m_threadActions.Count > 0)
                {
                    m_tempActions.AddRange(m_threadActions);
                    m_threadActions.Clear();
                }

                // 网络相关回调
                if (m_netActions.Count > 0)
                {
                    m_tempActions.AddRange(m_netActions);
                    m_netActions.Clear();
                }
            }

            if (m_tempActions.Count > 0)
            {
                foreach (Action action in m_tempActions)
                {
                    try
                    {
                        action();
                    }
                    catch (Exception e)
                    {
                        Logger.LogException(e);
                    }
                }
                m_tempActions.Clear();
            }


            // 设备方向有变化
            if (DeviceHelper.Update())
            {
                ScreenOrientationHandler.Call();
            }

            // 屏幕尺寸有改变
            if (Screen.width != m_screenSize.x || Screen.height != m_screenSize.y)
            {
                m_screenSize.Set(Screen.width, Screen.height);
                ResizeHandler.Call();
                DispatchLuaEvent(EVENT_RESIZE);
            }

            // 全局屏幕 Touch 相关
            StageTouchEventDispatcher.Update();

            // lua Update
            DispatchLuaEvent(EVENT_UPDATE);
        }