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 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; } ClientStack = new MockStack(layers, configClient) { StackName = "Client" }; MockStack stack = new MockStack(layers, configServer) { StackName = "Server #1" }; ServerStacks.Add(ServerAddress, new List <MockStack>() { stack }); stack.MyEndPoint = new MockEndpoint(this, stack, ServerAddress); ServerStacks.Add(MulticastAddress, new List <MockStack>() { stack }); MockDeliverer serverDeliverer = new MockDeliverer() { IsServer = true, Pump = this }; stack.MyEndPoint.MessageDeliverer = serverDeliverer; stack = new MockStack(layers, configServer) { StackName = "Server #2" }; ServerStacks.Add(ServerAddress2, new List <MockStack>() { stack }); stack.MyEndPoint = new MockEndpoint(this, stack, ServerAddress2); ServerStacks[MulticastAddress].Add(stack); serverDeliverer = new MockDeliverer() { IsServer = true, Pump = this }; stack.MyEndPoint.MessageDeliverer = serverDeliverer; ClientEndpoint = new MockEndpoint(this, ClientStack, ClientAddress); ClientDeliverer = new MockDeliverer() { IsServer = false, Pump = this }; ClientEndpoint.MessageDeliverer = ClientDeliverer; }