Hie.Core.Endpoints.TcpReceiveEndpoint.Initialize C# (CSharp) Méthode

Initialize() public méthode

public Initialize ( IApplicationHost host, IOptions options ) : void
host IApplicationHost
options IOptions
Résultat void
		public override void Initialize(IApplicationHost host, IOptions options)
		{
			_hostService = host;
			if (options != null)
			{
				_options = (TcpReceieveOptions) options;

				// Validate options (since this will be coming from a human)
				_options.Validate();
			}
		}

Usage Example

Exemple #1
0
        public void TcpReceiveEndpointMultiByteDelimitersTest()
        {
            var options = new TcpReceieveOptions();

            options.SohDelimiters = new byte[] { TcpReceieveOptions.SOH, 0x06 };
            options.StxDelimiters = new byte[] { TcpReceieveOptions.STX, 0x06 };
            options.EtxDelimiters = new byte[] { TcpReceieveOptions.ETX, 0x06 };
            options.EotDelimiters = new byte[] { TcpReceieveOptions.EOT, 0x07 };
            //BUG: If the end-delimiter of STX and EOT match it will not detect EOT
            //options.EOTDelimiters = new byte[] {TcpReceiveEndpoint.EOT, 0x06};

            TcpReceiveEndpoint endpoint = new TcpReceiveEndpoint(new IPEndPoint(IPAddress.Any, 6789), options);
            var host = new Mock <IApplicationHost>();

            endpoint.Initialize(host.Object, options);

            StateObject state = new StateObject(null);

            List <byte> data = new List <byte>();

            data.AddRange(options.SohDelimiters);
            data.AddRange(options.StxDelimiters);
            data.AddRange(new byte[] { 0x41, 0x41, 0x41, 0x41 });
            data.AddRange(options.EtxDelimiters);
            data.AddRange(options.EotDelimiters);
            data.CopyTo(state.Buffer, 0);

            bool isEot = endpoint.ProcessIncomingStream(state.Buffer.Length, state);

            Assert.IsTrue(isEot);
            host.Verify(app => app.ProcessInPipeline(It.IsAny <TcpReceiveEndpoint>(), It.IsNotNull <byte[]>()), Times.Once);
            host.Verify(app => app.ProcessInPipeline(It.IsAny <TcpReceiveEndpoint>(), It.Is <byte[]>(indata => indata.SequenceEqual(new byte[] { 0x41, 0x41, 0x41, 0x41 }))));
        }
All Usage Examples Of Hie.Core.Endpoints.TcpReceiveEndpoint::Initialize