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.message.OutgoingDatagramMessage;
20 import org.fourthline.cling.model.message.UpnpRequest;
21 import org.fourthline.cling.model.message.header.HostHeader;
22 import org.fourthline.cling.model.message.header.MANHeader;
23 import org.fourthline.cling.model.message.header.MXHeader;
24 import org.fourthline.cling.model.message.header.UpnpHeader;
25 import org.fourthline.cling.model.types.NotificationSubtype;
26 import org.fourthline.cling.model.ModelUtil;
27
28
29
30
31 public class OutgoingSearchRequest extends OutgoingDatagramMessage<UpnpRequest> {
32
33 private UpnpHeader searchTarget;
34
35 public OutgoingSearchRequest(UpnpHeader searchTarget, int mxSeconds) {
36 super(
37 new UpnpRequest(UpnpRequest.Method.MSEARCH),
38 ModelUtil.getInetAddressByName(Constants.IPV4_UPNP_MULTICAST_GROUP),
39 Constants.UPNP_MULTICAST_PORT
40 );
41
42 this.searchTarget = searchTarget;
43
44 getHeaders().add(UpnpHeader.Type.MAN, new MANHeader(NotificationSubtype.DISCOVER.getHeaderString()));
45 getHeaders().add(UpnpHeader.Type.MX, new MXHeader(mxSeconds));
46 getHeaders().add(UpnpHeader.Type.ST, searchTarget);
47 getHeaders().add(UpnpHeader.Type.HOST, new HostHeader());
48 }
49
50 public UpnpHeader getSearchTarget() {
51 return searchTarget;
52 }
53 }