final String status = "status message";
System.err.println(status.length());
final RequestFilter<CoapMessage, CoapMessage> rq = new RequestFilter<>();
NioUdpClient client = new NioUdpClient();
client.setFilters( //
new ProtocolCodecFilter<CoapMessage, ByteBuffer, Void, Void>( //
new CoapEncoder(), new CoapDecoder() //
), rq);
client.setIoHandler(new Handler());
reg.register(new AbstractResourceHandler() {
@Override
public CoapResponse handle(CoapMessage request, IoSession session) {
if (request.getCode() == CoapCode.GET.getCode()) {
return new CoapResponse(CoapCode.CONTENT.getCode(), status.getBytes());
} else {
return new CoapResponse(CoapCode.METHOD_NOT_ALLOWED.getCode(), null);
}
}
@Override
public String getTittle() {
return "Status report";
}
@Override
public String getPath() {
return "st";
}
});
IoFuture<IoSession> cf = client.connect(new InetSocketAddress(args[0], Integer.parseInt(args[1])));
// register on connection
cf.register(new AbstractIoFutureListener<IoSession>() {
@Override