當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。