1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.fourthline.cling.model.message.discovery;
17
18 import org.fourthline.cling.model.Constants;
19 import org.fourthline.cling.model.Location;
20 import org.fourthline.cling.model.message.header.LocationHeader;
21 import org.fourthline.cling.model.meta.LocalDevice;
22 import org.fourthline.cling.model.ModelUtil;
23 import org.fourthline.cling.model.message.OutgoingDatagramMessage;
24 import org.fourthline.cling.model.message.UpnpRequest;
25 import org.fourthline.cling.model.message.header.HostHeader;
26 import org.fourthline.cling.model.message.header.NTSHeader;
27 import org.fourthline.cling.model.message.header.ServerHeader;
28 import org.fourthline.cling.model.message.header.UpnpHeader;
29 import org.fourthline.cling.model.message.header.MaxAgeHeader;
30 import org.fourthline.cling.model.types.NotificationSubtype;
31
32
33
34
35 public abstract class OutgoingNotificationRequest extends OutgoingDatagramMessage<UpnpRequest> {
36
37 private NotificationSubtype type;
38
39 protected OutgoingNotificationRequest(Location location, LocalDevice device, NotificationSubtype type) {
40 super(
41 new UpnpRequest(UpnpRequest.Method.NOTIFY),
42 ModelUtil.getInetAddressByName(Constants.IPV4_UPNP_MULTICAST_GROUP),
43 Constants.UPNP_MULTICAST_PORT
44 );
45
46 this.type = type;
47
48 getHeaders().add(UpnpHeader.Type.MAX_AGE, new MaxAgeHeader(device.getIdentity().getMaxAgeSeconds()));
49 getHeaders().add(UpnpHeader.Type.LOCATION, new LocationHeader(location.getURL()));
50
51 getHeaders().add(UpnpHeader.Type.SERVER, new ServerHeader());
52 getHeaders().add(UpnpHeader.Type.HOST, new HostHeader());
53 getHeaders().add(UpnpHeader.Type.NTS, new NTSHeader(type));
54 }
55
56 public NotificationSubtype getType() {
57 return type;
58 }
59
60 }