View Javadoc

1   /*
2    * Copyright  2004-2005 Stefan Reuter
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *
16   */
17  package net.sf.asterisk.manager.event;
18  
19  /***
20   * A PeerStatusEvent is triggered when a SIP or IAX client attempts to registrer at this asterisk
21   * server.<br>
22   * This event is implemented in <code>channels/chan_iax2.c</code> and
23   * <code>channels/chan_sip.c</code>
24   * 
25   * @author srt
26   * @version $Id: PeerStatusEvent.java,v 1.3 2005/08/28 10:37:55 srt Exp $
27   */
28  public class PeerStatusEvent extends ManagerEvent
29  {
30      /***
31       * Serializable version identifier
32       */
33      private static final long serialVersionUID = 8384939771592846892L;
34      private String peer;
35      private String peerStatus;
36      private String cause;
37      private Integer time;
38  
39      /***
40       * @param source
41       */
42      public PeerStatusEvent(Object source)
43      {
44          super(source);
45      }
46  
47      /***
48       * Returns the name of the peer that registered. The peer's name starts with "IAX2/" if it is an
49       * IAX client or "SIP/" if it is a SIP client. It is followed by the username that is used for
50       * registration.
51       */
52      public String getPeer()
53      {
54          return peer;
55      }
56  
57      /***
58       * Sets the name of the peer that registered.
59       */
60      public void setPeer(String peer)
61      {
62          this.peer = peer;
63      }
64  
65      /***
66       * Returns the registration state.<br>
67       * This may be one of
68       * <ul>
69       * <li>Registered</li>
70       * <li>Unregistered</li>
71       * <li>Reachable</li>
72       * <li>Lagged</li>
73       * <li>Unreachable</li>
74       * <li>Rejected (IAX only)</li>
75       * </ul>
76       */
77      public String getPeerStatus()
78      {
79          return peerStatus;
80      }
81  
82      /***
83       * Sets the registration state.
84       */
85      public void setPeerStatus(String peerStatus)
86      {
87          this.peerStatus = peerStatus;
88      }
89  
90      /***
91       * Returns the cause of a rejection or unregistration.<br>
92       * For IAX peers this is set only if the status equals "Rejected".<br>
93       * For SIP peers this is set if the status equals "Unregistered" and the peer was unregistered
94       * due to an expiration. In that case the cause is set to "Expired".
95       */
96      public String getCause()
97      {
98          return cause;
99      }
100 
101     /***
102      * Sets the cause of the rejection or unregistration.
103      */
104     public void setCause(String cause)
105     {
106         this.cause = cause;
107     }
108 
109     /***
110      * Returns the ping time of the client if status equals "Reachable" or "Lagged"; if the status
111      * equals "Unreachable" it returns how long the last response took (in ms) for IAX peers or -1
112      * for SIP peers.
113      */
114     public Integer getTime()
115     {
116         return time;
117     }
118 
119     public void setTime(Integer time)
120     {
121         this.time = time;
122     }
123 }