Ejemplo n.º 1
0
    protected override void OnDestroy()
    {
        if (onProxyConnected != null)
        {
            onProxyConnected.Dispose();
            onProxyConnected = null;
        }
        if (onProxyRecv != null)
        {
            onProxyRecv.Dispose();
            onProxyRecv = null;
        }
        if (proxyClient != null)
        {
            proxyClient.Close();
            proxyClient = null;
        }
        if (onConnected != null)
        {
            onConnected.Dispose();
            onConnected = null;
        }
        if (onRecv != null)
        {
            onRecv.Dispose();
            onRecv = null;
        }
        networking.TcpIpServer.Shutdown();

        base.OnDestroy();
    }
Ejemplo n.º 2
0
 public void Dispose()
 {
     lock (this)
     {
         if (logPack != null)
         {
             logPack.Dispose();
             logPack = null;
         }
         if (onInit != null)
         {
             onInit.Dispose();
             onInit = null;
         }
     }
 }
Ejemplo n.º 3
0
 protected override void OnDestroy()
 {
     if (onConnected != null)
     {
         onConnected.Dispose();
         onConnected = null;
     }
     if (onRecv != null)
     {
         onRecv.Dispose();
         onRecv = null;
     }
     if (client != null)
     {
         client.Close();
         client = null;
     }
     base.OnDestroy();
 }
Ejemplo n.º 4
0
        LuaFunction Cache(string name, bool renew = false, LuaFunction withFunc = null)
        {
            LuaFunction f = null;

            if (cached.TryGetValue(name, out f))
            {
                if (!renew)
                {
                    return(f);
                }

                // renew, dispose current
                if (f != null)
                {
                    f.Dispose();
                }
                if (withFunc != null)
                {
                    cached[name] = withFunc;
                }
            }
            var L   = CheckValid();
            var top = Api.lua_gettop(L);

            Push();
            if (Api.lua_getfield(L, -1, name) == Api.LUA_TFUNCTION)
            {
                f = LuaFunction.MakeRefTo(L, -1);
            }
            else
            {
                Config.LogError(string.Format("attempt to call a non-function '{0}' ", name));
            }
            cached[name] = f;
            Api.lua_settop(L, top);
            return(f);
        }