Esempio n. 1
0
    protected void RemoveFromOpenedSockList(NetSock sock)
    {
        if (CoresConfig.SocketLogSettings.DisableSocketLog == false)
        {
            try
            {
                LogDefSocket log = sock.GenerateLogDef(LogDefSocketAction.Disconnected);
                log.NetworkSystem = this.ToString();
                LocalLogRouter.PostSocketLog(log, LogTag.SocketDisconnected);
            }
            catch (Exception ex)
            {
                ex._Debug();
            }
        }

        lock (LockObj)
            OpenedSockList.Remove(sock);

        //if (OpenedSockList.Count == 0)
        //{
        //    Dbg.Where();
        //    Dbg.GcCollect();
        //}
    }
Esempio n. 2
0
    protected void AddToOpenedSockList(NetSock sock, string logTag)
    {
        lock (LockObj)
        {
            sock.Id = (++IdSeed);
            OpenedSockList.Add(sock);
        }

        sock.AddOnCancelAction(async() =>
        {
            this.RemoveFromOpenedSockList(sock);
            await Task.CompletedTask;
        })._LaissezFaire();

        if (CoresConfig.SocketLogSettings.DisableSocketLog == false)
        {
            try
            {
                LogDefSocket log = sock.GenerateLogDef(LogDefSocketAction.Connected);
                log.NetworkSystem = this.ToString();
                LocalLogRouter.PostSocketLog(log, logTag);
            }
            catch (Exception ex)
            {
                ex._Debug();
            }
        }
    }