00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 package de.fhg.fokus.diameter.DiameterPeer.peer;
00032
00033 import java.util.Vector;
00034
00035 import org.apache.log4j.Logger;
00036
00037 import de.fhg.fokus.diameter.DiameterPeer.DiameterPeer;
00038 import de.fhg.fokus.diameter.DiameterPeer.data.DiameterMessage;
00039 import de.fhg.fokus.diameter.DiameterPeer.transport.Communicator;
00051 public class Peer {
00052
00054 private static final Logger LOGGER = Logger.getLogger(Peer.class);
00055
00057 public DiameterPeer diameterPeer;
00058
00060 public String FQDN;
00061
00063 public int port;
00064
00066 public String Realm;
00067
00069 public int state=StateMachine.Closed;
00070
00072 public Communicator I_comm;
00073
00075 public Communicator R_comm;
00076
00078 public long lastReceiveTime;
00079
00081 public boolean waitingDWA=false;
00082
00084 public boolean isDynamicPeer=false;
00085
00087 public Vector<Application> AuthApp;
00088
00090 public Vector<Application> AcctApp;
00091
00092
00093
00101 public Peer(String fqdn, String realm, int port) {
00102 FQDN = fqdn;
00103 Realm = realm;
00104 this.port = port;
00105 this.AuthApp = new Vector<Application>();
00106 this.AcctApp = new Vector<Application>();
00107 }
00108
00109
00118 public boolean sendMessage(DiameterMessage msg)
00119 {
00120 switch (this.state){
00121 case StateMachine.I_Open:
00122
00123
00124 return I_comm.sendMessage(msg);
00125 case StateMachine.R_Open:
00126
00127
00128 return R_comm.sendMessage(msg);
00129 default:
00130 System.err.println("Peer: Can't send message when not connected");
00131 return false;
00132 }
00133 }
00134
00139 public void refreshTimer()
00140 {
00141 this.lastReceiveTime = System.currentTimeMillis();
00142 }
00143 }