当前位置: 首页>>代码示例>>Java>>正文


Java UpnpHeader类代码示例

本文整理汇总了Java中org.fourthline.cling.model.message.header.UpnpHeader的典型用法代码示例。如果您正苦于以下问题:Java UpnpHeader类的具体用法?Java UpnpHeader怎么用?Java UpnpHeader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UpnpHeader类属于org.fourthline.cling.model.message.header包,在下文中一共展示了UpnpHeader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: applyRequestHeaders

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
protected void applyRequestHeaders() {
    // Headers
    UpnpHeaders headers = getRequestMessage().getHeaders();
    if (log.isLoggable(Level.FINE))
        log.fine("Writing headers on HttpContentExchange: " + headers.size());
    // TODO Always add the Host header
    // TODO: ? setRequestHeader(UpnpHeader.Type.HOST.getHttpName(), );
    // Add the default user agent if not already set on the message
    if (!headers.containsKey(UpnpHeader.Type.USER_AGENT)) {
        setRequestHeader(
                UpnpHeader.Type.USER_AGENT.getHttpName(),
                getConfiguration().getUserAgentValue(
                        getRequestMessage().getUdaMajorVersion(),
                        getRequestMessage().getUdaMinorVersion())
        );
    }
    for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
        for (String v : entry.getValue()) {
            String headerName = entry.getKey();
            if (log.isLoggable(Level.FINE))
                log.fine("Setting header '" + headerName + "': " + v);
            addRequestHeader(headerName, v);
        }
    }
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:26,代码来源:ArchosStreamClientImpl.java

示例2: isSupportedServiceAdvertisement

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
protected boolean isSupportedServiceAdvertisement(IncomingDatagramMessage message) {
    ServiceType[] exclusiveServiceTypes = getUpnpService().getConfiguration().getExclusiveServiceTypes();
    if (exclusiveServiceTypes == null) return false; // Discovery is disabled
    if (exclusiveServiceTypes.length == 0) return true; // Any advertisement is fine

    String usnHeader = message.getHeaders().getFirstHeader(UpnpHeader.Type.USN.getHttpName());
    if (usnHeader == null) return false; // Not a service advertisement, drop it

    try {
        NamedServiceType nst = NamedServiceType.valueOf(usnHeader);
        for (ServiceType exclusiveServiceType : exclusiveServiceTypes) {
            if (nst.getServiceType().implementsVersion(exclusiveServiceType))
                return true;
        }
    } catch (InvalidValueException ex) {
        log.finest("Not a named service type header value: " + usnHeader);
    }
    log.fine("Service advertisement not supported, dropping it: " + usnHeader);
    return false;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:21,代码来源:ProtocolFactoryImpl.java

示例3: OutgoingActionRequestMessage

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
public OutgoingActionRequestMessage(ActionInvocation actionInvocation, URL controlURL) {
    this(actionInvocation.getAction(), new UpnpRequest(UpnpRequest.Method.POST, controlURL));

    // For proxy remote invocations, pass through the user agent header
    if (actionInvocation instanceof RemoteActionInvocation) {
        RemoteActionInvocation remoteActionInvocation = (RemoteActionInvocation) actionInvocation;
        if (remoteActionInvocation.getRemoteClientInfo() != null
            && remoteActionInvocation.getRemoteClientInfo().getRequestUserAgent() != null) {
            getHeaders().add(
                UpnpHeader.Type.USER_AGENT,
                new UserAgentHeader(remoteActionInvocation.getRemoteClientInfo().getRequestUserAgent())
            );
        }
    } else if (actionInvocation.getClientInfo() != null) {
        getHeaders().putAll(actionInvocation.getClientInfo().getRequestHeaders());
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:18,代码来源:OutgoingActionRequestMessage.java

示例4: IncomingActionRequestMessage

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
public IncomingActionRequestMessage(StreamRequestMessage source,
                                    LocalService service) throws ActionException {
    super(source);

    SoapActionHeader soapActionHeader = getHeaders().getFirstHeader(UpnpHeader.Type.SOAPACTION, SoapActionHeader.class);
    if (soapActionHeader == null) {
        throw new ActionException(ErrorCode.INVALID_ACTION, "Missing SOAP action header");
    }

    SoapActionType actionType = soapActionHeader.getValue();

    this.action = service.getAction(actionType.getActionName());
    if (this.action == null) {
        throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't implement action: " + actionType.getActionName());
    }

    if (!QueryStateVariableAction.ACTION_NAME.equals(actionType.getActionName())) {
        if (!service.getServiceType().implementsVersion(actionType.getServiceType())) {
            throw new ActionException(ErrorCode.INVALID_ACTION, "Service doesn't support the requested service version");
        }
    }

    this.actionNamespace = actionType.getTypeString();
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:25,代码来源:IncomingActionRequestMessage.java

示例5: getRootDeviceUDN

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
public UDN getRootDeviceUDN() {
    // This processes the headers as specified in UDA 1.0, tables in section 1.1.12

    UpnpHeader<UDN> udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, USNRootDeviceHeader.class);
    if (udnHeader != null) return udnHeader.getValue();

    udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, UDNHeader.class);
    if (udnHeader != null) return udnHeader.getValue();

    UpnpHeader<NamedDeviceType> deviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, DeviceUSNHeader.class);
    if (deviceTypeHeader != null) return deviceTypeHeader.getValue().getUdn();

    UpnpHeader<NamedServiceType> serviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, ServiceUSNHeader.class);
    if (serviceTypeHeader != null) return serviceTypeHeader.getValue().getUdn();

    return null;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:18,代码来源:IncomingSearchResponse.java

示例6: OutgoingNotificationRequest

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
protected OutgoingNotificationRequest(Location location, LocalDevice device, NotificationSubtype type) {
    super(
            new UpnpRequest(UpnpRequest.Method.NOTIFY),
            ModelUtil.getInetAddressByName(Constants.IPV4_UPNP_MULTICAST_GROUP),
            Constants.UPNP_MULTICAST_PORT
    );

    this.type = type;

    getHeaders().add(UpnpHeader.Type.MAX_AGE, new MaxAgeHeader(device.getIdentity().getMaxAgeSeconds()));
    getHeaders().add(UpnpHeader.Type.LOCATION, new LocationHeader(location.getURL()));

    getHeaders().add(UpnpHeader.Type.SERVER, new ServerHeader());
    getHeaders().add(UpnpHeader.Type.HOST, new HostHeader());
    getHeaders().add(UpnpHeader.Type.NTS, new NTSHeader(type));
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:17,代码来源:OutgoingNotificationRequest.java

示例7: OutgoingSearchResponse

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
public OutgoingSearchResponse(IncomingDatagramMessage request,
                              Location location,
                              LocalDevice device) {

    super(new UpnpResponse(UpnpResponse.Status.OK), request.getSourceAddress(), request.getSourcePort());

    getHeaders().add(UpnpHeader.Type.MAX_AGE, new MaxAgeHeader(device.getIdentity().getMaxAgeSeconds()));
    getHeaders().add(UpnpHeader.Type.LOCATION, new LocationHeader(location.getURL()));
    getHeaders().add(UpnpHeader.Type.SERVER, new ServerHeader());
    getHeaders().add(UpnpHeader.Type.EXT, new EXTHeader());

    if (location.getNetworkAddress().getHardwareAddress() != null) {
        getHeaders().add(
                UpnpHeader.Type.EXT_IFACE_MAC,
                 new InterfaceMacHeader(location.getNetworkAddress().getHardwareAddress())
        );
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:19,代码来源:OutgoingSearchResponse.java

示例8: getUDN

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
/**
 * @return The UDN value after parsing various USN header values, or <code>null</code>.
 */
public UDN getUDN() {
    // This processes the headers as specified in UDA 1.0, tables in section 1.1.12

    UpnpHeader<UDN> udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, USNRootDeviceHeader.class);
    if (udnHeader != null) return udnHeader.getValue();

    udnHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, UDNHeader.class);
    if (udnHeader != null) return udnHeader.getValue();

    UpnpHeader<NamedDeviceType> deviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, DeviceUSNHeader.class);
    if (deviceTypeHeader != null) return deviceTypeHeader.getValue().getUdn();

    UpnpHeader<NamedServiceType> serviceTypeHeader = getHeaders().getFirstHeader(UpnpHeader.Type.USN, ServiceUSNHeader.class);
    if (serviceTypeHeader != null) return serviceTypeHeader.getValue().getUdn();

    return null;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:21,代码来源:IncomingNotificationRequest.java

示例9: OutgoingRenewalRequestMessage

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
public OutgoingRenewalRequestMessage(RemoteGENASubscription subscription,
                                     UpnpHeaders extraHeaders) {

    super(UpnpRequest.Method.SUBSCRIBE, subscription.getEventSubscriptionURL());

    getHeaders().add(
            UpnpHeader.Type.SID,
            new SubscriptionIdHeader(subscription.getSubscriptionId())
    );

    getHeaders().add(
            UpnpHeader.Type.TIMEOUT,
            new TimeoutHeader(subscription.getRequestedDurationSeconds())
    );

    if (extraHeaders != null)
        getHeaders().putAll(extraHeaders);
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:19,代码来源:OutgoingRenewalRequestMessage.java

示例10: OutgoingSubscribeRequestMessage

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
public OutgoingSubscribeRequestMessage(RemoteGENASubscription subscription,
                                       List<URL> callbackURLs,
                                       UpnpHeaders extraHeaders) {

    super(UpnpRequest.Method.SUBSCRIBE, subscription.getEventSubscriptionURL());

    getHeaders().add(
            UpnpHeader.Type.CALLBACK,
            new CallbackHeader(callbackURLs)
    );

    getHeaders().add(
            UpnpHeader.Type.NT,
            new NTEventHeader()
    );

    getHeaders().add(
            UpnpHeader.Type.TIMEOUT,
            new TimeoutHeader(subscription.getRequestedDurationSeconds())
    );

    if (extraHeaders != null)
        getHeaders().putAll(extraHeaders);
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:25,代码来源:OutgoingSubscribeRequestMessage.java

示例11: OutgoingEventRequestMessage

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
public OutgoingEventRequestMessage(GENASubscription subscription,
                                   URL callbackURL,
                                   UnsignedIntegerFourBytes sequence,
                                   Collection<StateVariableValue> values) {

    super(new UpnpRequest(UpnpRequest.Method.NOTIFY, callbackURL));

    getHeaders().add(UpnpHeader.Type.CONTENT_TYPE, new ContentTypeHeader());
    getHeaders().add(UpnpHeader.Type.NT, new NTEventHeader());
    getHeaders().add(UpnpHeader.Type.NTS, new NTSHeader(NotificationSubtype.PROPCHANGE));
    getHeaders().add(UpnpHeader.Type.SID, new SubscriptionIdHeader(subscription.getSubscriptionId()));

    // Important! Pass by value so that we can safely increment it afterwards and before this is send!
    getHeaders().add(UpnpHeader.Type.SEQ, new EventSequenceHeader(sequence.getValue()));

    this.stateVariableValues = values;
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:18,代码来源:OutgoingEventRequestMessage.java

示例12: log

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
@Override
public void log() {
    if (log.isLoggable(Level.FINE)) {
        super.log();
        if (parsedDLNAHeaders != null && parsedDLNAHeaders.size() > 0) {
            log.fine("########################## PARSED DLNA HEADERS ##########################");
            for (Map.Entry<DLNAHeader.Type, List<UpnpHeader>> entry : parsedDLNAHeaders.entrySet()) {
                log.log(Level.FINE, "=== TYPE: {0}", entry.getKey());
                for (UpnpHeader upnpHeader : entry.getValue()) {
                    log.log(Level.FINE, "HEADER: {0}", upnpHeader);
                }
            }
        }
        log.fine("####################################################################");
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:17,代码来源:DLNAHeaders.java

示例13: getRequestParams

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
protected HttpParams getRequestParams(StreamRequestMessage requestMessage) {
    HttpParams localParams = new BasicHttpParams();

    localParams.setParameter(
        CoreProtocolPNames.PROTOCOL_VERSION,
        requestMessage.getOperation().getHttpMinorVersion() == 0 ? HttpVersion.HTTP_1_0 : HttpVersion.HTTP_1_1
    );

    // DefaultHttpClient adds HOST header automatically in its default processor

    // Add the default user agent if not already set on the message
    if (!requestMessage.getHeaders().containsKey(UpnpHeader.Type.USER_AGENT)) {
        HttpProtocolParams.setUserAgent(
            localParams,
            getConfiguration().getUserAgentValue(requestMessage.getUdaMajorVersion(), requestMessage.getUdaMinorVersion())
        );
    }

    return new DefaultedHttpParams(localParams, globalParams);
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:21,代码来源:StreamClientImpl.java

示例14: applyRequestProperties

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
protected void applyRequestProperties(HttpURLConnection urlConnection, StreamRequestMessage requestMessage) {

        urlConnection.setInstanceFollowRedirects(false); // Defaults to true but not needed here

        // HttpURLConnection always adds a "Host" header

        // HttpURLConnection always adds an "Accept" header (not needed but shouldn't hurt)

        // Add the default user agent if not already set on the message
        if (!requestMessage.getHeaders().containsKey(UpnpHeader.Type.USER_AGENT)) {
            urlConnection.setRequestProperty(
                UpnpHeader.Type.USER_AGENT.getHttpName(),
                getConfiguration().getUserAgentValue(requestMessage.getUdaMajorVersion(), requestMessage.getUdaMinorVersion())
            );
        }

        // Other headers
        applyHeaders(urlConnection, requestMessage.getHeaders());
    }
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:20,代码来源:StreamClientImpl.java

示例15: applyRequestHeaders

import org.fourthline.cling.model.message.header.UpnpHeader; //导入依赖的package包/类
protected void applyRequestHeaders() {
    // Headers
    UpnpHeaders headers = getRequestMessage().getHeaders();
    if (log.isLoggable(Level.FINE))
        log.fine("Writing headers on HttpContentExchange: " + headers.size());
    // TODO Always add the Host header
    // TODO: ? setRequestHeader(UpnpHeader.Type.HOST.getHttpName(), );
    // Add the default user agent if not already set on the message
    if (!headers.containsKey(UpnpHeader.Type.USER_AGENT)) {
        setRequestHeader(
            UpnpHeader.Type.USER_AGENT.getHttpName(),
            getConfiguration().getUserAgentValue(
                getRequestMessage().getUdaMajorVersion(),
                getRequestMessage().getUdaMinorVersion())
        );
    }
    for (Map.Entry<String, List<String>> entry : headers.entrySet()) {
        for (String v : entry.getValue()) {
            String headerName = entry.getKey();
            if (log.isLoggable(Level.FINE))
                log.fine("Setting header '" + headerName + "': " + v);
            addRequestHeader(headerName, v);
        }
    }
}
 
开发者ID:offbye,项目名称:DroidDLNA,代码行数:26,代码来源:StreamClientImpl.java


注:本文中的org.fourthline.cling.model.message.header.UpnpHeader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。