List of usage examples for io.netty.buffer ByteBuf writeCharSequence
public abstract int writeCharSequence(CharSequence sequence, Charset charset);
From source file:org.traccar.protocol.WristbandProtocolDecoder.java
License:Apache License
private void sendResponse(Channel channel, String imei, String version, int type, String data) { if (channel != null) { String sentence = String.format("YX%s|%s|0|{F%02d#%s}\r\n", imei, version, type, data); ByteBuf response = Unpooled.buffer(); if (type != 91) { response.writeBytes(new byte[] { 0x00, 0x01, 0x02 }); response.writeShort(sentence.length()); }/*from ww w. java2 s.c om*/ response.writeCharSequence(sentence, StandardCharsets.US_ASCII); if (type != 91) { response.writeBytes(new byte[] { (byte) 0xFF, (byte) 0xFE, (byte) 0xFC }); } channel.writeAndFlush(new NetworkMessage(response, channel.remoteAddress())); } }