Exemple #1
0
        private static void Timer_Elapsed(object sender)
        {
            byte[]    data    = new byte[] { 1, 2, 3 };
            AosBody   aosBody = new AosBody(data, 1);
            AosHeader header  = new AosHeader(ProtocolTypeEnum.AddBzn, aosBody.Length);

            aosTcpClient?.Send(header.ToByteArray());
            aosTcpClient?.Send(aosBody.ToByteArray());
        }
Exemple #2
0
        private static void AosTcpClient_AosHeaderReceivedEvent(object sender, AosHeaderEventArgs e)
        {
            Console.WriteLine($"Header: type: {e.Request.ProtocolType}, body size: {e.Request.BodySize}");

            if (e.Request.ProtocolType == ProtocolTypeEnum.SetBznRequest)
            {
                byte[]    data    = new byte[] { 1, 2, 3 };
                AosBody   aosBody = new AosBody(data, 1);
                AosHeader header  = new AosHeader(ProtocolTypeEnum.SetBznRespose, aosBody.Length);

                aosTcpClient.Send(header.ToByteArray());
                aosTcpClient.Send(aosBody.ToByteArray());
            }
        }
Exemple #3
0
        public static async Task <AosBody> ReadBodyAsync(this TcpClient client, int size)
        {
            var body = await ReadAsync(client, size);

            return(AosBody.ToAosBody(body));
        }