public MockEndpoint AddEndPoint(string endpointName, IPEndPoint endPoint, ICoapConfig config, Type[] layers, bool isServer, bool useMockDelivery = false, IResource root = null)
        {
            MockStack stack = new MockStack(layers, config)
            {
                StackName = endpointName
            };

            MockEndpoint ep = new MockEndpoint(this, stack, endPoint);

            stack.MyEndPoint = ep;

            if (useMockDelivery)
            {
                ep.MessageDeliverer = new MockDeliverer()
                {
                    IsServer = isServer,
                    Pump     = this
                };
            }
            else
            {
                ep.MessageDeliverer = isServer ? new ServerMessageDeliverer(config, root) : (IMessageDeliverer) new ClientMessageDeliverer();
            }

            ServerStacks.Add(endPoint, new List <MockStack>()
            {
                stack
            });

            return(ep);
        }
 public MockEndpoint(MockMessagePump pump, MockStack stack, EndPoint myAddress)
 {
     Outbox  = this;
     Pump    = pump;
     Stack   = stack;
     Matcher = new Matcher(CoapConfig.Default);
     Matcher.Start();
     MyAddress = myAddress;
     Session   = new MockSession();
 }
        public void AddEndpointToAddress(IPEndPoint ipAddress, MockStack endPoint)
        {
            List <MockStack> stacks;

            if (!ServerStacks.TryGetValue(ipAddress, out stacks))
            {
                stacks = new List <MockStack>();
                ServerStacks.Add(ipAddress, stacks);
            }

            stacks.Add(endPoint);
        }
        public MockMessagePump(Type[] layers, ICoapConfig configClient = null, ICoapConfig configServer = null)
        {
            if (configClient == null)
            {
                configClient = CoapConfig.Default;
            }

            if (configServer == null)
            {
                configServer = CoapConfig.Default;
            }

            ClientEndpoint = AddClientEndpoint("Client", (IPEndPoint)ClientAddress, configClient, layers, true);
            ClientStack    = ServerStacks[ClientAddress].First();

            AddServerEndpoint("Server #1", (IPEndPoint)ServerAddress, configServer, layers, true);
            MockStack x = ServerStacks[ServerAddress].First();

            AddEndpointToAddress((IPEndPoint)MulticastAddress, x);

            AddServerEndpoint("Server #2", (IPEndPoint)ServerAddress2, configServer, layers, true);
            x = ServerStacks[ServerAddress2].First();
            AddEndpointToAddress((IPEndPoint)MulticastAddress, x);
        }