Пример #1
0
        protected virtual void ClientConnected(TcpClient client)
        {
            //prepare session
            var connection = new HttpConnection()
            {
                NetworkClient = client,
                Ip            = client.Client.RemoteEndPoint is IPEndPoint iPEndPoint
                    ? iPEndPoint.Address.ToString()
                    : client.Client.RemoteEndPoint?.ToString(),
            };

            AllConnections.Add(connection);
            //listen to connection
            _ = Task.Run(async() => await SafeClientStartListen(connection)).ConfigureAwait(false);
        }
 private bool AddAdmin(string[] args)
 {
     if (UserSupplied(args))
     {
         string   user             = rebuildString(args);
         ZNet     zNet             = ZNet.instance;
         ZNetPeer peerByPlayerName = zNet.GetPeerByPlayerName(user);
         if (peerByPlayerName != null)
         {
             user = peerByPlayerName.m_socket.GetHostName();
         }
         print("Adding player to the admin list: " + user);
         SyncedList adminList = (SyncedList)AccessTools.Field(typeof(ZNet), "m_adminList").GetValue(zNet);
         adminList.Add(user);
         AccessTools.Field(typeof(ZNet), "m_adminList").SetValue(zNet, adminList);
         return(true);
     }
     return(false);
 }
 private bool Permit(string[] args)
 {
     if (UserSupplied(args))
     {
         string   user             = rebuildString(args);
         ZNet     zNet             = ZNet.instance;
         ZNetPeer peerByPlayerName = zNet.GetPeerByPlayerName(user);
         if (peerByPlayerName != null)
         {
             user = peerByPlayerName.m_socket.GetHostName();
         }
         print("Permitting user: "******"m_permittedList").GetValue(zNet);
         permittedPlayers.Add(user);
         AccessTools.Field(typeof(ZNet), "m_permittedList").SetValue(zNet, permittedPlayers);
         return(true);
     }
     return(false);
 }
Пример #4
0
        protected SyncedList<Segment> CreateSegments(long totalSize, long segmentSize)
        {
            try
            {
                SyncedList<Segment> segments = new SyncedList<Segment>();
                long nombreSegments = totalSize / segmentSize;
                long lastSegmentSize = 0;
                for (int i = 0; i < nombreSegments; i++)
                {
                    segments.Add(new Segment(segmentSize, i * segmentSize, this, this.manager));
                }

                lastSegmentSize = totalSize % segmentSize;
                if (lastSegmentSize != 0)
                {
                    segments.Add(new Segment(lastSegmentSize, segmentSize * nombreSegments, this, this.manager));
                }
                return segments;

            }
            catch (Exception ex)
            {
                AddErrorMsg("Download.CreateSegments() ", ex);
                return null;
            }
        }