本文整理匯總了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();
}