Skip to content

Commit

Permalink
Remove deprecated code usage
Browse files Browse the repository at this point in the history
  • Loading branch information
akolosov-n committed Aug 19, 2024
1 parent 3403185 commit d754382
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions coap-core/src/main/java/com/mbed/coap/packet/CoapPacket.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ public static CoapPacket from(SeparateResponse resp) {
}

public CoapResponse toCoapResponse() {
return CoapResponse.of(code, payload, options);
return CoapResponse.of(code, payload, options).withContext(this.transportContext);
}

public SeparateResponse toSeparateResponse() {
return toCoapResponse().toSeparate(getToken(), getRemoteAddress(), getTransportContext());
return toCoapResponse().toSeparate(getToken(), getRemoteAddress());
}

public InetSocketAddress getRemoteAddress() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public SeparateResponse toSeparate(Opaque token, InetSocketAddress peerAddress,
}

public SeparateResponse toSeparate(Opaque token, InetSocketAddress peerAddress) {
return toSeparate(token, peerAddress, TransportContext.EMPTY);
return new SeparateResponse(this, token, peerAddress);
}

public TransportContext getTransContext() {
Expand Down Expand Up @@ -180,6 +180,7 @@ public CoapResponse build() {
return new CoapResponse(code, payload, options.build(), transContext);
}

@Deprecated
public SeparateResponse toSeparate(Opaque token, InetSocketAddress peerAddress, TransportContext transContext) {
return build().toSeparate(token, peerAddress, transContext);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void handle(CoapPacket packet) {

// RESPONSE
if (packet.getCode() != null) {
SeparateResponse resp = packet.toCoapResponse().toSeparate(packet.getToken(), packet.getRemoteAddress(), packet.getTransportContext());
SeparateResponse resp = packet.toCoapResponse().toSeparate(packet.getToken(), packet.getRemoteAddress());
if (outboundHandler.apply(resp)) {
return;
}
Expand Down

0 comments on commit d754382

Please sign in to comment.