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);
        }
예제 #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;
 }
예제 #3
0
            public ProxyCommunicator(ICoapConfig config)
            {
                _coapStack = new CoapStack(config);
                _httpStack = new HttpStack(config.HttpPort);

                _coapStack.RegisterReceiver(this);
                _httpStack.RegisterReceiver(this);
            }
예제 #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" };
 }
예제 #5
0
 public CommonCommunicator(ICoapConfig config)
 {
     _coapStack = new CoapStack(config);
     LowerLayer = _coapStack;
 }