當前位置: 首頁>>代碼示例>>Java>>正文


Java Channel.localAddress方法代碼示例

本文整理匯總了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();
}
 
開發者ID:ctripcorp,項目名稱:cornerstone,代碼行數:21,代碼來源:VINettyHandler.java

示例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;
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:22,代碼來源:BaseServerHandler.java

示例3: setChannel

import io.netty.channel.Channel; //導入方法依賴的package包/類
public void setChannel(Channel channel){
    this.channel = channel;
    super.remoteAddress = channel.remoteAddress();
    super.localAddress = channel.localAddress();
}
 
開發者ID:tiglabs,項目名稱:jsf-sdk,代碼行數:6,代碼來源:JSFClientTransport.java

示例4: getLocalAddress

import io.netty.channel.Channel; //導入方法依賴的package包/類
@Override
protected InetSocketAddress getLocalAddress(Channel channel) {
    return (InetSocketAddress) channel.localAddress();
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:5,代碼來源:Netty4Transport.java


注:本文中的io.netty.channel.Channel.localAddress方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。