Esempio n. 1
0
        public static void Post_Lua(string url, string function, lua.LuaTable parameter, lua.LuaFunction complete, WebRequest2.Context context = null, string parametersStr = "")
        {
            Dictionary <string, object> param = new Dictionary <string, object>();

            if (parameter != null)
            {
                var L = luaVm;
                parameter.Push();
                Api.lua_pushnil(L);
                while (Api.lua_next(L, -2) != 0)
                {
                    var key   = Api.lua_tostring(L, -2);
                    var value = L.ValueAt(-1);
                    param.Add(key, value);
                    Api.lua_pop(L, 1);             // pop value
                }
                Api.lua_pop(L, 1);                 // pop table
            }

            var localComplete = complete.Retain();

            WebRequest2.Post(new System.Uri(url), function, param,
                             (s, resCode, payload, cookies, headers, localContext) =>
            {
                if (s == WebExceptionStatus.Success && resCode == HttpStatusCode.OK)
                {
                    localComplete.Invoke(true, payload);
                }
                else
                {
                    localComplete.Invoke(false);
                }
                localComplete.Dispose();
            }, context, parametersStr);
        }
Esempio n. 2
0
 public void Connect(string addr, int port, lua.LuaFunction onConnected, lua.LuaFunction onRecv)
 {
     client           = new networking.TcpIpClient();
     this.onConnected = onConnected.Retain();
     this.onRecv      = onRecv.Retain();
     client.Connect(addr, port, OnConnected);
 }
Esempio n. 3
0
 public EncryptedChanModule(lua.LuaFunction onInit = null)
 {
     if (onInit != null)
     {
         this.onInit = onInit.Retain();
     }
 }
Esempio n. 4
0
    public void Serve(ushort port, lua.LuaFunction onConnected, lua.LuaFunction onRecv)
    {
        this.onConnected = onConnected.Retain();
        this.onRecv      = onRecv.Retain();
        networking.TcpIpServer.Serve(port, OnConnected);

#if UNITY_EDITOR
        var x      = 100;
        var y      = 60;
        var width  = 200;
        var height = 80;
        Editor_AddGraph_Native(
            "server_send", "kbps", GetSendBandwidth, 10, 0.5f,
            x, y, width, height, Color.red);

        y += height + 5;
        Editor_AddGraph_Native(
            "server_recv", "kbps", GetRecvBandwidth, 10, 0.5f,
            x, y, width, height, Color.blue);

        y += height + 5;
        Editor_AddGraph_Native(
            "proxy_send", "kbps", GetProxySendBandwidth, 10, 0.5f,
            x, y, width, height, Color.red);

        y += height + 5;
        Editor_AddGraph_Native(
            "proxy_recv", "kbps", GetProxyRecvBandwidth, 10, 0.5f,
            x, y, width, height, Color.blue);
#endif
    }
Esempio n. 5
0
 public void ConnectProxy(string addr, int port, lua.LuaFunction onConnected, lua.LuaFunction onRecv)
 {
     proxyClient      = new networking.TcpIpClient();
     onProxyConnected = onConnected.Retain();
     onProxyRecv      = onRecv.Retain();
     proxyClient.Connect(addr, port, OnProxyConnected);
 }
Esempio n. 6
0
        public static void Download_Lua(string url, lua.LuaFunction complete)
        {
            var localComplete = complete.Retain();

            WebRequest2.Download(url, (data) =>
            {
                localComplete.Invoke(data);
                localComplete.Dispose();
            });
        }
Esempio n. 7
0
 public ActionSlot(LuaFunction f)
 {
     func = f.Retain();
 }