Beispiel #1
0
 static int UF_closeAllConnection(IntPtr L)
 {
     #if UNITY_EDITOR
     if (!LuaDLL.lua_isboolean(L, 1))
     {
         LuaDLL.luaL_typerror(L, 1, "boolean");
     }
     #endif
     bool notifyState = LuaDLL.lua_toboolean(L, 1);
     NetworkSystem.UF_GetInstance().UF_CloseAllConnection(notifyState);
     return(0);
 }
        internal void SendPoint(int pointId, string deviceChunk, string userChunk)
        {
            string param = string.Format("&reason={0}{1}{2}", pointId, deviceChunk, userChunk);
            string url   = urlCheckPoint + param;

            Debugger.UF_Log("Check Point:" + url);
            //FrameHandle.UF_AddCoroutine(SendRequest(url));

            NetworkSystem.UF_GetInstance().UF_HttpGetRequest(url, "", 5000, null);

            //for (int k = 0; k < 100; k++) {
            //    NetworkSystem.UF_GetInstance().HttpGetRequest(url, "", 5000, (a,e)=> { idx++; Debug.Log(e.ToString() + "| " + idx); });
            //}
        }
Beispiel #3
0
        static int UF_httpDownload(IntPtr L)
        {
                        #if UNITY_EDITOR
            if (LuaDLL.lua_isstring(L, 1) == 0)
            {
                LuaDLL.luaL_typerror(L, 1, "string");
            }
            if (LuaDLL.lua_isstring(L, 2) == 0)
            {
                LuaDLL.luaL_typerror(L, 2, "string");
            }
            if (LuaDLL.lua_isnumber(L, 3) == 0)
            {
                LuaDLL.luaL_typerror(L, 3, "number");
            }
                        #endif

            string url      = LuaDLL.lua_tostring(L, 1);
            string headinfo = LuaDLL.lua_tostring(L, 2);
            int    timeout  = (int)LuaDLL.lua_tonumber(L, 3);

            DelegateResponse callback = null;
            if (LuaDLL.lua_isfunction(L, 4))
            {
                LuaFunction luafunction = ToLua.ToLuaFunction(L, 4);

                callback = delegate(int retcode, object param) {
//					string msg = string.Empty;
                    byte[] data = param as byte[];

                    LuaFunction func = luafunction;
                    func.BeginPCall();
                    func.Push(retcode);
                    if (data != null)
                    {
                        uint uniCode = m_TableBytes.UF_Add(data);
                        func.Push(uniCode);
                    }
                    func.PCall();
                    func.EndPCall();
                };
            }

            NetworkSystem.UF_GetInstance().UF_HttpGetRequest(url, headinfo, timeout, callback);
            return(0);
        }
Beispiel #4
0
        static int UF_sendTo(IntPtr L)
        {
                        #if UNITY_EDITOR
            if (LuaDLL.lua_isstring(L, 1) == 0)
            {
                LuaDLL.luaL_typerror(L, 1, "string");
            }
            if (LuaDLL.lua_isnumber(L, 2) == 0)
            {
                LuaDLL.luaL_typerror(L, 2, "number");
            }
            if (LuaDLL.lua_isnumber(L, 3) == 0)
            {
                LuaDLL.luaL_typerror(L, 3, "number");
            }
            if (LuaDLL.lua_isnumber(L, 4) == 0)
            {
                LuaDLL.luaL_typerror(L, 4, "number");
            }
            if (LuaDLL.lua_isnumber(L, 5) == 0)
            {
                LuaDLL.luaL_typerror(L, 5, "number");
            }
                        #endif

            string host     = LuaDLL.lua_tostring(L, 1);
            int    port     = (int)LuaDLL.lua_tonumber(L, 2);
            int    protocol = (int)LuaDLL.lua_tonumber(L, 3);
            int    corcode  = (int)LuaDLL.lua_tonumber(L, 4);
            uint   bufferid = (uint)LuaDLL.lua_tonumber(L, 5);

            CBytesBuffer buffer = m_TableCBytesBuffer[bufferid];
            UF_ASSERT_BYTESBUFFER(buffer);

            //			buffer.pack ();

            NetworkSystem.UF_GetInstance().UF_SendMessage(host, port, protocol, corcode, buffer.Buffer, buffer.DataSize);

            return(0);
        }
Beispiel #5
0
        static int UF_httpUpload(IntPtr L)
        {
                        #if UNITY_EDITOR
            if (LuaDLL.lua_isstring(L, 1) == 0)
            {
                LuaDLL.luaL_typerror(L, 1, "string");
            }
            if (LuaDLL.lua_isstring(L, 2) == 0)
            {
                LuaDLL.luaL_typerror(L, 2, "string");
            }
            if (LuaDLL.lua_isstring(L, 3) == 0)
            {
                LuaDLL.luaL_typerror(L, 3, "string");
            }
            if (LuaDLL.lua_isnumber(L, 4) == 0)
            {
                LuaDLL.luaL_typerror(L, 4, "number");
            }
                        #endif

            string url      = LuaDLL.lua_tostring(L, 1);
            string filePath = LuaDLL.lua_tostring(L, 2);
            string headinfo = LuaDLL.lua_tostring(L, 3);
            int    timeout  = (int)LuaDLL.lua_tonumber(L, 4);

            DelegateResponse callback = null;
            if (LuaDLL.lua_isfunction(L, 5))
            {
                LuaFunction luafunction = ToLua.ToLuaFunction(L, 5);
                callback = delegate(int retcode, object param) {
                    UF_OnHttpResponse(luafunction, retcode, param);
                };
            }

            NetworkSystem.UF_GetInstance().UF_HttpUploadFile(url, filePath, headinfo, timeout, callback);

            return(0);
        }
Beispiel #6
0
        static int UF_checkConnected(IntPtr L)
        {
                        #if UNITY_EDITOR
            if (LuaDLL.lua_isstring(L, 1) == 0)
            {
                LuaDLL.luaL_typerror(L, 1, "string");
            }
            if (LuaDLL.lua_isnumber(L, 2) == 0)
            {
                LuaDLL.luaL_typerror(L, 2, "number");
            }
                        #endif

            string host = LuaDLL.lua_tostring(L, 1);
            int    port = (int)LuaDLL.lua_tonumber(L, 2);

            bool ret = NetworkSystem.UF_GetInstance().UF_CheckNetConnected(host, port);

            LuaDLL.lua_pushboolean(L, ret);

            return(1);
        }
Beispiel #7
0
 public void UF_DrawDetail(Rect rect)
 {
     if (GUILayout.Button("Info", GUILayout.Height(40)))
     {
         m_CurrentTag = TAG_INFO;
     }
     if (GUILayout.Button("Protocal", GUILayout.Height(40)))
     {
         m_CurrentTag = TAG_PROTOCAL;
     }
     if (GUILayout.Button("Hack", GUILayout.Height(40)))
     {
         m_CurrentTag = TAG_HACK;
     }
     GUILayout.Space(40);
     GUI.color = Color.red;
     if (GUILayout.Button("BreakAll", GUILayout.Height(40)))
     {
         //测试断开所有链接
         NetworkSystem.UF_GetInstance().UF_CloseAllConnection(true);
     }
     GUI.color = Color.white;
 }
Beispiel #8
0
        static int UF_httpDownloadTo(IntPtr L)
        {
                        #if UNITY_EDITOR
            if (LuaDLL.lua_isstring(L, 1) == 0)
            {
                LuaDLL.luaL_typerror(L, 1, "string");
            }
            if (LuaDLL.lua_isstring(L, 2) == 0)
            {
                LuaDLL.luaL_typerror(L, 2, "string");
            }
            if (LuaDLL.lua_isnumber(L, 3) == 0)
            {
                LuaDLL.luaL_typerror(L, 3, "number");
            }
            if (LuaDLL.lua_isstring(L, 4) == 0)
            {
                LuaDLL.luaL_typerror(L, 4, "string");
            }
                        #endif

            string url       = LuaDLL.lua_tostring(L, 1);
            string headinfo  = LuaDLL.lua_tostring(L, 2);
            int    timeout   = (int)LuaDLL.lua_tonumber(L, 3);
            string localPath = LuaDLL.lua_tostring(L, 4);

            if (!System.IO.Directory.Exists(System.IO.Path.GetDirectoryName(localPath)))
            {
                System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(localPath));
            }

            DelegateResponse callback = null;
            if (LuaDLL.lua_isfunction(L, 5))
            {
                LuaFunction luafunction = ToLua.ToLuaFunction(L, 5);

                callback = delegate(int retcode, object param) {
//					string msg = string.Empty;
                    byte[] data = param as byte[];
                    //save to local
                    try{
                        if (System.IO.File.Exists(localPath))
                        {
                            System.IO.File.Delete(localPath);
                        }

                        System.IO.FileInfo   fi = new System.IO.FileInfo(localPath);
                        System.IO.FileStream fs = fi.Open(System.IO.FileMode.CreateNew);
                        fs.Write(data, 0, data.Length);
                        fs.Close();
                    }catch (System.Exception e) {
                        Debugger.UF_Exception(e);
                    }

                    LuaFunction func = luafunction;
                    func.BeginPCall();
                    func.Push(retcode);
                    func.PCall();
                    func.EndPCall();
                };
            }

            NetworkSystem.UF_GetInstance().UF_HttpGetRequest(url, headinfo, timeout, callback);
            return(0);
        }
Beispiel #9
0
 //网络信息,链接,网速等
 private void UF_DrawTagInfo()
 {
     GUILayout.Space(4);
     GUILayout.Box(NetworkSystem.UF_GetInstance().ToString());
     GUILayout.Space(4);
 }
Beispiel #10
0
 public void UF_OnAwake()
 {
     hostAddress = NetworkSystem.UF_GetInstance().UF_GetHostIP();
 }
Beispiel #11
0
 internal void UF_SendUrl(string urlChunk)
 {
     Debugger.UF_Log("Check Url:" + urlChunk);
     //FrameHandle.UF_AddCoroutine(SendRequest(urlChunk));
     NetworkSystem.UF_GetInstance().UF_HttpGetRequest(urlChunk, "", 5000, null);
 }