Example usage for io.netty.channel ChannelId asLongText

List of usage examples for io.netty.channel ChannelId asLongText

Introduction

In this page you can find the example usage for io.netty.channel ChannelId asLongText.

Prototype

String asLongText();

Source Link

Document

Returns the long yet globally unique string representation of the ChannelId .

Usage

From source file:com.caricah.iotracah.server.netty.channelgroup.IotChannelGroup.java

License:Apache License

@Override
public Channel find(ChannelId id) {
    Channel c = nonServerChannels.get(id.asLongText());
    if (c != null) {
        return c;
    } else {//from   w  w w.j a v  a 2  s  . c  om
        return serverChannels.get(id.asLongText());
    }
}

From source file:net.anyflow.lannister.TestUtil.java

License:Apache License

static public ChannelId newChannelId(String clientId, boolean newChannelId) {
    return new ChannelId() {
        private static final long serialVersionUID = 3931333967922160660L;

        Long idPostfix = Hazelcast.SELF.generator().getIdGenerator("unittest_embeddedchannel").newId();

        @Override//from   w  w  w  . j a v a2 s. c  o m
        public int compareTo(ChannelId o) {
            return this.asLongText().equals(o.asLongText()) ? 0 : 1;
        }

        @Override
        public String asShortText() {
            return asLongText();
        }

        @Override
        public String asLongText() {
            if (newChannelId) {
                return clientId + idPostfix.toString();
            } else {
                return clientId;
            }
        }

        @Override
        public int hashCode() {
            if (newChannelId) {
                return (clientId + idPostfix.toString()).hashCode();
            } else {
                return clientId.hashCode();
            }
        }

        @Override
        public String toString() {
            return asLongText();
        }
    };
}