本文整理汇总了Java中io.netty.channel.Channel.localAddress方法的典型用法代码示例。如果您正苦于以下问题:Java Channel.localAddress方法的具体用法?Java Channel.localAddress怎么用?Java Channel.localAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.netty.channel.Channel
的用法示例。
在下文中一共展示了Channel.localAddress方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRequestURL
import io.netty.channel.Channel; //导入方法依赖的package包/类
private String getRequestURL(Channel channel,HttpRequest req){
StringBuffer url = new StringBuffer();
String scheme = isSecure(channel)?"https":"http";
InetSocketAddress addr = (InetSocketAddress)channel.localAddress();
int port = addr.getPort();
String urlPath = req.getUri();
url.append(scheme); // http, https
url.append("://");
url.append(EnFactory.getEnHost().getHostAddress());
if (("http".equalsIgnoreCase(scheme) && port != 80)
|| ("https".equalsIgnoreCase(scheme) && port != 443)) {
url.append(':');
url.append(port);
}
url.append(urlPath);
return url.toString();
}
示例2: getKey
import io.netty.channel.Channel; //导入方法依赖的package包/类
/**
* Get key.
*
* @param channel the channel
* @return the string
*/
public static String getKey(Channel channel){
InetSocketAddress local = (InetSocketAddress)channel.localAddress();
InetSocketAddress address = (InetSocketAddress)channel.remoteAddress();
StringBuilder sb = new StringBuilder();
sb.append(NetUtils.toIpString(address));
sb.append(":");
sb.append(address.getPort());
sb.append(" --> ");
sb.append(NetUtils.toIpString(local));
sb.append(":");
sb.append(local.getPort());
String key = sb.toString();
return key;
}
示例3: setChannel
import io.netty.channel.Channel; //导入方法依赖的package包/类
public void setChannel(Channel channel){
this.channel = channel;
super.remoteAddress = channel.remoteAddress();
super.localAddress = channel.localAddress();
}
示例4: getLocalAddress
import io.netty.channel.Channel; //导入方法依赖的package包/类
@Override
protected InetSocketAddress getLocalAddress(Channel channel) {
return (InetSocketAddress) channel.localAddress();
}