예제 #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());
        }
예제 #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());
            }
        }
예제 #3
0
        public static async Task <AosHeader> ReadHeaderAsync(this TcpClient client)
        {
            var header = await ReadAsync(client, AosHeader.Length);

            return(AosHeader.ToAosHeader(header));
        }