Skip to content

Commit

Permalink
CoapServerGroup: return underlying transports
Browse files Browse the repository at this point in the history
  • Loading branch information
szysas committed Aug 30, 2024
1 parent c9bf0bb commit 7111342
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 6 additions & 2 deletions coap-core/src/main/java/com/mbed/coap/server/CoapServer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2023 java-coap contributors (https://github.com/open-coap/java-coap)
* Copyright (C) 2022-2024 java-coap contributors (https://github.com/open-coap/java-coap)
* Copyright (C) 2011-2021 ARM Limited. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -33,7 +33,7 @@
public class CoapServer {
private static final Logger LOGGER = LoggerFactory.getLogger(CoapServer.class);
private final AtomicBoolean isRunning = new AtomicBoolean(false);
private final CoapTransport transport;
final CoapTransport transport;
private final Consumer<CoapPacket> dispatcher;
private final Service<CoapRequest, CoapResponse> outboundService;
private final Service<SeparateResponse, Boolean> outboundResponseService;
Expand Down Expand Up @@ -129,4 +129,8 @@ public final Service<CoapRequest, CoapResponse> clientService() {
public Service<SeparateResponse, Boolean> outboundResponseService() {
return outboundResponseService;
}

CoapTransport getTransport() {
return transport;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import static com.mbed.coap.utils.Validations.require;
import static java.util.stream.Collectors.toList;
import com.mbed.coap.transport.CoapTransport;
import java.io.IOException;
import java.util.List;

Expand Down Expand Up @@ -48,4 +49,8 @@ public boolean isRunning() {
public List<Integer> getLocalPorts() {
return servers.stream().map(server -> server.getLocalSocketAddress().getPort()).collect(toList());
}

public List<CoapTransport> getTransports() {
return servers.stream().map(CoapServer::getTransport).collect(toList());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CoapServerGroupTest {
void test() throws Exception {
// given
CoapServerGroup servers = builder.buildGroup(3).start();
assertEquals(3, servers.getTransports().size());
CoapClient client = builder.buildClient(localhost(10_001));
CoapClient client2 = builder.buildClient(localhost(10_003));

Expand Down

0 comments on commit 7111342

Please sign in to comment.