Example usage for io.netty.buffer Unpooled EMPTY_BUFFER

List of usage examples for io.netty.buffer Unpooled EMPTY_BUFFER

Introduction

In this page you can find the example usage for io.netty.buffer Unpooled EMPTY_BUFFER.

Prototype

ByteBuf EMPTY_BUFFER

To view the source code for io.netty.buffer Unpooled EMPTY_BUFFER.

Click Source Link

Document

A buffer whose capacity is 0 .

Usage

From source file:ws.wamp.jawampa.WampClient.java

License:Apache License

private void closeCurrentTransport() {
    if (status == Status.Disconnected)
        return;//from  ww w  . j a va 2 s.c om

    if (channel != null) {
        channel.writeAndFlush(Unpooled.EMPTY_BUFFER).addListener(ChannelFutureListener.CLOSE);
        channel = null;
    }

    // If we are in the connect process mark the connect future as cancelled
    if (connectFuture != null)
        connectFuture.cancel(false);
    connectFuture = null;
    handler = null;

    // Stop the reconnect timer. In case of real reconnects
    // it will be initialized after closeCurrentTransport()
    if (reconnectSubscription != null) {
        reconnectSubscription.unsubscribe();
        reconnectSubscription = null;
    }

    welcomeDetails = null;
    sessionId = 0;

    status = Status.Disconnected;

    clearPendingRequests(new ApplicationError(ApplicationError.TRANSPORT_CLOSED));
    clearAllSubscriptions(null);
    clearAllRegisteredProcedures(null);
}

From source file:ws.wamp.jawampa.WampRouter.java

License:Apache License

private void closeActiveChannel(WampRouterHandler channel, WampMessage closeMessage) {
    if (channel == null)
        return;//from  w  ww. ja v  a 2  s .  c  o m

    channel.realm.removeChannel(channel, true);
    channel.markAsClosed();

    if (channel.ctx != null) {
        Object m = (closeMessage == null) ? Unpooled.EMPTY_BUFFER : closeMessage;
        channel.ctx.writeAndFlush(m).addListener(ChannelFutureListener.CLOSE);
    }
}