public static StompFrame newDisconnectFrame() { StompFrame frame = new StompControlFrame( Command.DISCONNECT ); frame.setHeader( Header.RECEIPT, "connection-close" ); return frame; }
public static StompFrame newReceiptFrame(String receiptId) { StompControlFrame receipt = new StompControlFrame( Command.RECEIPT ); receipt.setHeader( Header.RECEIPT_ID, receiptId ); return receipt; }
public ChannelBuffer encode(StompFrame frame) throws Exception { ChannelBuffer buffer = newBuffer( frame ); writeHeader( frame, buffer ); writeContent( frame, buffer ); return buffer; }
@Override public void channelConnected(ChannelHandlerContext context, ChannelStateEvent e) throws Exception { StompControlFrame frame = new StompControlFrame( Command.CONNECT ); frame.setHeader( Header.HOST, this.host ); frame.setHeader( Header.ACCEPT_VERSION, Version.supportedVersions() ); Channels.write( context.getChannel(), frame ); }
protected FrameHeader processHeaderLine(FrameHeader header, String line) { if (header == null) { header = new FrameHeader(); Command command = Command.valueOf( line ); header.setCommand( command ); return header; } int colonLoc = line.indexOf( ":" ); if (colonLoc > 0) { String name = line.substring( 0, colonLoc ); String value = line.substring( colonLoc + 1 ); header.set( name, value ); } return header; }
protected void handleStompFrame(ChannelHandlerContext channelContext, StompFrame frame) { if ( frame.getCommand().equals( this.command ) ) { handleControlFrame( channelContext, frame ); } }
/** * Creates a new embedder whose pipeline is composed of the specified * handlers. */ public HandlerEmbedder(boolean fireInitialEvents, ChannelHandler... handlers) { pipeline = new EmbeddedChannelPipeline(); configurePipeline( handlers ); channel = new EmbeddedChannel( pipeline, sink ); if (fireInitialEvents) { fireInitialEvents(); } }
public void closeRequested(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { this.closeRequest = e; StompFrame closeFrame = StompFrames.newDisconnectFrame(); this.receiptId = closeFrame.getHeader( Header.RECEIPT ); Channels.write( ctx.getChannel(), closeFrame ); }
public void eventSunk(ChannelPipeline pipeline, ChannelEvent e) { handleEvent( e ); }
@Override protected Object decode(ChannelHandlerContext ctx, Channel channel, ChannelBuffer buffer, VoidEnum state) throws Exception { return StompFrameCodec.INSTANCE.decode( buffer ); } }
@Override protected Object encode(ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception { if (msg instanceof StompFrame) { return StompFrameCodec.INSTANCE.encode( (StompFrame) msg ); } return msg; }
/** * Create a new outbound frame. * * @param command */ public StompFrame(Command command) { this.header = new FrameHeader( command ); }
public void setHeader(String name, String value) { this.header.set( name, value ); }
public Set<String> getHeaderNames() { return this.header.getNames(); }
public boolean isContentFrame() { return this.command.hasContent(); }
public static StompControlFrame newBeginFrame(String transactionId) { StompControlFrame frame = new StompControlFrame( Command.BEGIN ); frame.setHeader( Header.TRANSACTION, transactionId ); return frame; }
public void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) { handleEvent( e ); }
public static StompControlFrame newAbortFrame(String transactionId) { StompControlFrame frame = new StompControlFrame( Command.ABORT ); frame.setHeader( Header.TRANSACTION, transactionId ); return frame; }
public static StompControlFrame newCommitFrame(String transactionId) { StompControlFrame frame = new StompControlFrame( Command.COMMIT ); frame.setHeader( Header.TRANSACTION, transactionId ); return frame; }