static int Connect(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         ShibaInu.TcpSocket obj  = (ShibaInu.TcpSocket)ToLua.CheckObject <ShibaInu.TcpSocket>(L, 1);
         string             arg0 = ToLua.CheckString(L, 2);
         int arg1 = (int)LuaDLL.luaL_checknumber(L, 3);
         obj.Connect(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 连接到工具服务端,开始收集数据
        /// </summary>
        /// <param name="host">Host.</param>
        /// <param name="port">Port.</param>
        /// <param name="isUDP">If set to <c>true</c> is UD.</param>
        public static void Begin(string host, int port, bool isUDP)
        {
            GameObject  go       = Common.go;
            LuaProfiler profiler = go.GetComponent <LuaProfiler>();

            if (profiler == null)
            {
                profiler = go.AddComponent <LuaProfiler>();
            }
            else
            {
                if (profiler.enabled)
                {
                    return;
                }
                profiler.enabled = true;
            }

            s_isUDP = isUDP;
            if (isUDP)
            {
                if (s_udp == null)
                {
                    s_udp = new UdpSocket {
                        callback = EventCallback
                    };
                }
                s_udp.Connect(host, port, (uint)port);
            }
            else
            {
                if (s_tcp == null)
                {
                    s_tcp = new TcpSocket {
                        callback = EventCallback
                    };
                }
                s_tcp.Connect(host, port);
            }

            s_luaBegin.BeginPCall();
            s_luaBegin.PCall();
            s_luaBegin.EndPCall();

            Logger.Log("Begin!", "LuaProfiler");
        }