Skip to content

Commit

Permalink
Remove deprecated usage of new CoapEndpoint()
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Mar 1, 2018
1 parent 2112e13 commit 99dbc67
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ public LeshanClient build() {
if (endpointFactory != null) {
unsecuredEndpoint = endpointFactory.createUnsecuredEndpoint(localAddress, coapConfig, null);
} else {
unsecuredEndpoint = new CoapEndpoint(localAddress, coapConfig);
CoapEndpoint.CoapEndpointBuilder builder = new CoapEndpoint.CoapEndpointBuilder();
builder.setInetSocketAddress(localAddress);
builder.setNetworkConfig(coapConfig);
unsecuredEndpoint = builder.build();
}
}

Expand All @@ -255,7 +258,10 @@ public LeshanClient build() {
if (endpointFactory != null) {
securedEndpoint = endpointFactory.createSecuredEndpoint(dtlsConfig, coapConfig, null);
} else {
securedEndpoint = new CoapEndpoint(new DTLSConnector(dtlsConfig), coapConfig, null, null);
CoapEndpoint.CoapEndpointBuilder builder = new CoapEndpoint.CoapEndpointBuilder();
builder.setConnector(new DTLSConnector(dtlsConfig));
builder.setNetworkConfig(coapConfig);
securedEndpoint = builder.build();
}
}

Expand All @@ -264,6 +270,7 @@ public LeshanClient build() {
"All CoAP enpoints are deactivated, at least one endpoint should be activated");
}

return new LeshanClient(endpoint, unsecuredEndpoint, securedEndpoint, objectEnablers, coapConfig, additionalAttributes);
return new LeshanClient(endpoint, unsecuredEndpoint, securedEndpoint, objectEnablers, coapConfig,
additionalAttributes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ public void register_with_invalid_request() throws InterruptedException, IOExcep
coapRequest.getOptions().addUriQuery("ep=" + helper.currentEndpointIdentifier);

// send request
CoapEndpoint coapEndpoint = new CoapEndpoint(new InetSocketAddress(0));
CoapEndpoint.CoapEndpointBuilder builder = new CoapEndpoint.CoapEndpointBuilder();
builder.setInetSocketAddress(new InetSocketAddress(0));
CoapEndpoint coapEndpoint = builder.build();
coapEndpoint.start();
coapEndpoint.sendRequest(coapRequest);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ public void createRPKClient() {
config.setIdentity(clientPrivateKey, clientPublicKey);

CoapServer coapServer = new CoapServer();
coapServer.addEndpoint(new CoapEndpoint(new DTLSConnector(config.build()), NetworkConfig.getStandard()));
CoapEndpoint.CoapEndpointBuilder coapBuilder = new CoapEndpoint.CoapEndpointBuilder();
coapBuilder.setConnector(new DTLSConnector(config.build()));
coapBuilder.setNetworkConfig(new NetworkConfig());
coapServer.addEndpoint(coapBuilder.build());

LeshanClientBuilder builder = new LeshanClientBuilder(getCurrentEndpoint());
builder.setLocalAddress(clientAddress.getHostString(), clientAddress.getPort());
Expand All @@ -240,7 +243,10 @@ public void createX509CertClient(PrivateKey privatekey, Certificate[] trustedCer
config.setTrustStore(trustedCertificates);

CoapServer coapServer = new CoapServer();
coapServer.addEndpoint(new CoapEndpoint(new DTLSConnector(config.build()), NetworkConfig.getStandard()));
CoapEndpoint.CoapEndpointBuilder coapBuilder = new CoapEndpoint.CoapEndpointBuilder();
coapBuilder.setConnector(new DTLSConnector(config.build()));
coapBuilder.setNetworkConfig(new NetworkConfig());
coapServer.addEndpoint(coapBuilder.build());

LeshanClientBuilder builder = new LeshanClientBuilder(getCurrentEndpoint());
builder.setLocalAddress(clientAddress.getHostString(), clientAddress.getPort());
Expand Down

0 comments on commit 99dbc67

Please sign in to comment.