1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.fourthline.cling.model.message.gena;
17
18 import org.fourthline.cling.model.state.StateVariableValue;
19 import org.fourthline.cling.model.message.StreamRequestMessage;
20 import org.fourthline.cling.model.message.UpnpRequest;
21 import org.fourthline.cling.model.message.header.ContentTypeHeader;
22 import org.fourthline.cling.model.message.header.EventSequenceHeader;
23 import org.fourthline.cling.model.message.header.NTEventHeader;
24 import org.fourthline.cling.model.message.header.NTSHeader;
25 import org.fourthline.cling.model.message.header.SubscriptionIdHeader;
26 import org.fourthline.cling.model.message.header.UpnpHeader;
27 import org.fourthline.cling.model.types.NotificationSubtype;
28 import org.fourthline.cling.model.types.UnsignedIntegerFourBytes;
29 import org.fourthline.cling.model.gena.GENASubscription;
30
31 import java.net.URL;
32 import java.util.Collection;
33
34
35
36
37 public class OutgoingEventRequestMessage extends StreamRequestMessage {
38
39 final private Collection<StateVariableValue> stateVariableValues;
40
41 public OutgoingEventRequestMessage(GENASubscription subscription,
42 URL callbackURL,
43 UnsignedIntegerFourBytes sequence,
44 Collection<StateVariableValue> values) {
45
46 super(new UpnpRequest(UpnpRequest.Method.NOTIFY, callbackURL));
47
48 getHeaders().add(UpnpHeader.Type.CONTENT_TYPE, new ContentTypeHeader());
49 getHeaders().add(UpnpHeader.Type.NT, new NTEventHeader());
50 getHeaders().add(UpnpHeader.Type.NTS, new NTSHeader(NotificationSubtype.PROPCHANGE));
51 getHeaders().add(UpnpHeader.Type.SID, new SubscriptionIdHeader(subscription.getSubscriptionId()));
52
53
54 getHeaders().add(UpnpHeader.Type.SEQ, new EventSequenceHeader(sequence.getValue()));
55
56 this.stateVariableValues = values;
57 }
58
59 public OutgoingEventRequestMessage(GENASubscription subscription, URL callbackURL) {
60 this(subscription, callbackURL, subscription.getCurrentSequence(), subscription.getCurrentValues().values());
61 }
62
63 public Collection<StateVariableValue> getStateVariableValues() {
64 return stateVariableValues;
65 }
66 }