コード例 #1
0
        /// <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));
        }
コード例 #2
0
ファイル: Hub.cs プロジェクト: mkiela01/Harmony.NET
 /// <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;
コード例 #3
0
 /// <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;