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); }
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); }
public EncryptedChanModule(lua.LuaFunction onInit = null) { if (onInit != null) { this.onInit = onInit.Retain(); } }
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 }
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); }
public static void Download_Lua(string url, lua.LuaFunction complete) { var localComplete = complete.Retain(); WebRequest2.Download(url, (data) => { localComplete.Invoke(data); localComplete.Dispose(); }); }
public ActionSlot(LuaFunction f) { func = f.Retain(); }