Hi Guys
I have an android App and I would like to return a JSON with the next time where the device will report the next position. Example in 120 seconds.
I did override the method sendResponse in the class OsmAndProtocolDecoder.
This is my code
@Override
public void sendResponse(Channel channel, HttpResponseStatus status) {
if (channel != null) {
String jsonString = "{\"code\":\"0001\",\"message\":\"Location successfully received\", \"data\":{\"seconds\":\"120\", \"miliseconds\":\"120000\"}}";
byte[] bytesArray = jsonString.getBytes();
ByteBuf buffer = Unpooled.copiedBuffer(bytesArray);
FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_0, status, buffer);
response.headers().add(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes());
response.headers().set(HttpHeaderNames.CONTENT_TYPE, "application/json");
channel.writeAndFlush(response);
}
}
The problem is that this code is broken something because the locations are not inserted in the table tc_locations. Only the table tc_device is updated in the column lastUpdate but not in positionId column
If I remove the code, the locations are inserted correctly to tc_locations
Hi Guys
I have an android App and I would like to return a JSON with the next time where the device will report the next position. Example in 120 seconds.
I did override the method sendResponse in the class OsmAndProtocolDecoder.
This is my code
@Override public void sendResponse(Channel channel, HttpResponseStatus status) { if (channel != null) { String jsonString = "{\"code\":\"0001\",\"message\":\"Location successfully received\", \"data\":{\"seconds\":\"120\", \"miliseconds\":\"120000\"}}"; byte[] bytesArray = jsonString.getBytes(); ByteBuf buffer = Unpooled.copiedBuffer(bytesArray); FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_0, status, buffer); response.headers().add(HttpHeaderNames.CONTENT_LENGTH, response.content().readableBytes()); response.headers().set(HttpHeaderNames.CONTENT_TYPE, "application/json"); channel.writeAndFlush(response); } }
The problem is that this code is broken something because the locations are not inserted in the table tc_locations. Only the table tc_device is updated in the column lastUpdate but not in positionId column
If I remove the code, the locations are inserted correctly to tc_locations