public IEndPoint AddEndPoint(string endpointName, EndPoint address, ICoapConfig config, Type[] layers)
        {
            MockChannel  channel  = new MockChannel(address, this);
            CoAPEndPoint endpoint = new CoAPEndPoint(channel, config);

            if (layers != null)
            {
                CoapStack stack = endpoint.Stack;

                foreach (IEntry <ILayer, INextLayer> e in stack.GetAll().ToArray())
                {
                    if (e.Name == "head" || e.Name == "tail")
                    {
                        continue;
                    }
                    if (!layers.Contains(e.Filter.GetType()))
                    {
                        stack.Remove(e.Filter);
                    }
                }
            }

            ChannelsByEndpoint.Add(address, new List <MockChannel>()
            {
                channel
            });

            return(endpoint);
        }
Beispiel #2
0
 /// <summary>
 /// Instantiates a new endpoint with the
 /// specified channel and configuration.
 /// </summary>
 public CoAPEndPoint(IChannel channel, ICoapConfig config)
 {
     _config                = config;
     _channel               = channel;
     _matcher               = new Matcher(config);
     _coapStack             = new CoapStack(config);
     _channel.DataReceived += ReceiveData;
 }
Beispiel #3
0
            public ProxyCommunicator(ICoapConfig config)
            {
                _coapStack = new CoapStack(config);
                _httpStack = new HttpStack(config.HttpPort);

                _coapStack.RegisterReceiver(this);
                _httpStack.RegisterReceiver(this);
            }
Beispiel #4
0
 /// <summary>
 /// Instantiates a new endpoint with the
 /// specified channel and configuration.
 /// </summary>
 public CoAPEndPoint(IChannel channel, ICoapConfig config)
 {
     dataChannel = channel ?? throw new ArgumentNullException(nameof(channel));
     Config      = config;
     _matcher    = new Matcher(config);
     _coapStack  = new CoapStack(config);
     dataChannel.DataReceived += ReceiveData;
     EndpointSchema            = new [] { "coap", "coap+udp" };
 }
Beispiel #5
0
 public CommonCommunicator(ICoapConfig config)
 {
     _coapStack = new CoapStack(config);
     LowerLayer = _coapStack;
 }