Ejemplo n.º 1
0
        public XBeeResponse[] CollectResponses(int timeout = -1, IPacketFilter filter = null)
        {
            var listener = new PacketListener(filter);

            try
            {
                AddPacketListener(listener);
                return listener.GetPackets(timeout);
            }
            finally
            {
                RemovePacketListener(listener);
            }
        }
Ejemplo n.º 2
0
        public XBeeResponse Receive(Type expectedType = null, int timeout = PacketParser.DefaultParseTimeout)
        {
            var listener = new PacketListener(new PacketTypeFilter(expectedType ?? typeof(XBeeResponse)));

            try
            {
                AddPacketListener(listener);
                var responses =  listener.GetPackets(timeout);

                if (responses.Length == 0)
                    throw new XBeeTimeoutException();

                return responses[0];
            }
            finally
            {
                _parser.RemovePacketListener(listener);
            }
        }
Ejemplo n.º 3
0
 public AsyncSendResult BeginSend(XBeeRequest request, IPacketFilter filter = null, int timeout = 5000)
 {
     var responseListener = new PacketListener(filter, timeout);
     AddPacketListener(responseListener);
     SendRequest(request);
     return new AsyncSendResult(this, responseListener);
 }