View Javadoc
1   /*
2    * Copyright (C) 2013 4th Line GmbH, Switzerland
3    *
4    * The contents of this file are subject to the terms of either the GNU
5    * Lesser General Public License Version 2 or later ("LGPL") or the
6    * Common Development and Distribution License Version 1 or later
7    * ("CDDL") (collectively, the "License"). You may not use this file
8    * except in compliance with the License. See LICENSE.txt for more
9    * information.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14   */
15  
16  package org.fourthline.cling.model.message;
17  
18  import java.net.InetAddress;
19  
20  /**
21   * A UDP datagram request or response message for sending, with destination address and port.
22   *
23   * @author Christian Bauer
24   */
25  public abstract class OutgoingDatagramMessage<O extends UpnpOperation> extends UpnpMessage<O> {
26  
27      private InetAddress destinationAddress;
28      private int destinationPort;
29      // For performance reasons, headers of this message are not normalized
30      private UpnpHeaders headers = new UpnpHeaders(false);
31  
32      protected OutgoingDatagramMessage(O operation, InetAddress destinationAddress, int destinationPort) {
33          super(operation);
34          this.destinationAddress = destinationAddress;
35          this.destinationPort = destinationPort;
36      }
37  
38      protected OutgoingDatagramMessage(O operation, BodyType bodyType, Object body, InetAddress destinationAddress, int destinationPort) {
39          super(operation, bodyType, body);
40          this.destinationAddress = destinationAddress;
41          this.destinationPort = destinationPort;
42      }
43  
44      public InetAddress getDestinationAddress() {
45          return destinationAddress;
46      }
47  
48      public int getDestinationPort() {
49          return destinationPort;
50      }
51      
52      @Override
53      public UpnpHeaders getHeaders() {
54          return this.headers;
55      }
56  }