@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 public int hashCode() { int result = super.hashCode(); result = 31 * result + code; return result; } }
@Override public String toString() { return super.toString() + ", body='" + body + "'"; }
@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); } } } }
@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); } } } }
@Override public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { log.debug("In webapp socket encoder {}", msg); if (msg instanceof MessageBase) { MessageBase message = (MessageBase) msg; ByteBuf out = ByteBufAllocator.DEFAULT.buffer(); out.writeByte(message.command); out.writeShort(message.id); if (message instanceof ResponseMessage) { out.writeInt(((ResponseMessage) message).code); } else { byte[] body = message.getBytes(); if (body.length > 0) { out.writeBytes(body); } } super.write(ctx, new BinaryWebSocketFrame(out), promise); } else { super.write(ctx, msg, promise); } } }
@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); }