/// <summary>
        ///     Called when a client has been accepted on the listener
        /// </summary>
        /// <param name="client">The client that has been accepted</param>
        private void OnClientAccepted(TcpClient client)
        {
            // Harmony seems to think that the data can never exceed 1024 bytes. Okay I guess
            byte[] Buffer     = new byte[1024];
            int    BytesRead  = client.GetStream().Read(Buffer, 0, Buffer.Length);
            string ClientData = Encoding.UTF8.GetString(Buffer, 0, BytesRead);

            // probably not hub info
            if (!ClientData.Contains(";"))
            {
                return;
            }

            HubInfo HubInfo = HubInfo.Parse(ClientData);

            if (this.FoundHubIDs.Contains(HubInfo.UUID))
            {
                return;
            }

            this.FoundHubIDs.Add(HubInfo.UUID);
            this.HubFound?.Invoke(this, new HubFoundEventArgs(HubInfo));
        }
Beispiel #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Hub" /> class.
 /// </summary>
 /// <param name="hubInfo">The hub's IP address and name info, usually obtained via discovery</param>
 public Hub(HubInfo hubInfo) => this.Info = hubInfo;
 /// <inheritdoc />
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:Harmony.HubFoundEventArgs" /> class.
 /// </summary>
 /// <param name="hubInfo">The Hub that was found</param>
 public HubFoundEventArgs(HubInfo hubInfo) => this.HubInfo = hubInfo;