@Override public String toString() { return "RegisterMessage{" + super.toString() + "}"; } }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + code; return result; } }
@Override public String toString() { return super.toString() + ", body='" + body + "'"; }
if (command == Command.RESPONSE) { int responseCode = (int) in.readUnsignedInt(); message = new ResponseMessage(messageId, responseCode); } else { int length = (int) in.readUnsignedInt(); byte[] bytes = new byte[buf.readableBytes()]; buf.readBytes(bytes); message = new BinaryMessage(messageId, command, bytes); break; default: message = produce(messageId, command, buf.toString(StandardCharsets.UTF_8));
public static StringMessage makeUTF8StringMessage(short cmd, int msgId, String data) { return new StringMessage(msgId, cmd, data); }
public static ResponseMessage makeResponse(int msgId, int responseCode) { return new ResponseMessage(msgId, responseCode); }
public static BinaryMessage makeBinaryMessage(short cmd, int msgId, byte[] byteData) { return new BinaryMessage(msgId, cmd, byteData); }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (!(o instanceof ResponseMessage)) { return false; } if (!super.equals(o)) { return false; } ResponseMessage that = (ResponseMessage) o; return code == that.code; }
@Override protected void encode(ChannelHandlerContext ctx, MessageBase message, ByteBuf out) { out.writeByte(message.command); out.writeShort(message.id); if (message instanceof ResponseMessage) { out.writeShort(((ResponseMessage) message).code); } else { stats.mark(message.command); byte[] body = message.getBytes(); out.writeShort(body.length); if (body.length > 0) { out.writeBytes(body); } } } }
if (command == Command.RESPONSE) { int responseCode = in.readUnsignedShort(); message = new ResponseMessage(messageId, responseCode); } else { int length = in.readUnsignedShort(); byte[] bytes = new byte[buf.readableBytes()]; buf.readBytes(bytes); message = new BinaryMessage(messageId, command, bytes); break; default: message = produce(messageId, command, buf.toString(StandardCharsets.UTF_8));
public static StringMessage makeASCIIStringMessage(short cmd, int msgId, String data) { return new StringMessage(msgId, cmd, data, StandardCharsets.US_ASCII); }
@Override public String toString() { return "LoginMessage{" + super.toString() + "}"; } }
@Override public int hashCode() { int result = super.hashCode(); result = 31 * result + (body != null ? body.hashCode() : 0); return result; } }
@Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } if (!super.equals(o)) { return false; } StringMessage that = (StringMessage) o; return !(body != null ? !body.equals(that.body) : that.body != null); }
@Override protected void encode(ChannelHandlerContext ctx, MessageBase message, ByteBuf out) { out.writeByte(message.command); out.writeShort(message.id); if (message instanceof ResponseMessage) { out.writeInt(((ResponseMessage) message).code); } else { stats.mark(message.command); byte[] body = message.getBytes(); out.writeInt(body.length); if (body.length > 0) { out.writeBytes(body); } } } }
public HardwareClient(String host, int port) { super(host, port, new Random()); log.info("Creating hardware client. Host : {}, port : {}", host, port); //pinging for hardware client to avoid closing from server side for inactivity nioEventLoopGroup.scheduleAtFixedRate(() -> send(new StringMessage(777, PING, "")), 12, 12, TimeUnit.SECONDS); }
@Override public String toString() { return "ResetPasswordMessage{" + super.toString() + "}"; } }
@Override public String toString() { return "GetServerMessage{" + super.toString() + "}"; } }
@Override public String toString() { return "HardwareMessage{" + super.toString() + "}"; } }
@Override public String toString() { return "ShareLoginMessage{" + super.toString() + "}"; } }