diff options
author | Damian Minkov <damencho@jitsi.org> | 2008-05-21 11:13:45 +0000 |
---|---|---|
committer | Damian Minkov <damencho@jitsi.org> | 2008-05-21 11:13:45 +0000 |
commit | 622f534356360fcf10d74700c2de08bafde67c75 (patch) | |
tree | 05cf409a4b7f679316f6108e3f53998f502adc89 /src/net/java/sip | |
parent | 28effe7f88b4861d1974162f49e37bd1cee4de63 (diff) | |
download | jitsi-622f534356360fcf10d74700c2de08bafde67c75.zip jitsi-622f534356360fcf10d74700c2de08bafde67c75.tar.gz jitsi-622f534356360fcf10d74700c2de08bafde67c75.tar.bz2 |
Disconnect if keep-alive options timeout.
Diffstat (limited to 'src/net/java/sip')
3 files changed, 33 insertions, 4 deletions
diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ClientCapabilities.java b/src/net/java/sip/communicator/impl/protocol/sip/ClientCapabilities.java index 5d0f328..2c0e94f 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ClientCapabilities.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ClientCapabilities.java @@ -13,6 +13,7 @@ import javax.sip.header.*; import java.text.*; import java.util.*; import java.net.*; +import java.io.*; import net.java.sip.communicator.util.*; import net.java.sip.communicator.service.protocol.*; import net.java.sip.communicator.service.protocol.event.*; @@ -161,6 +162,7 @@ public class ClientCapabilities */ public void processTimeout(TimeoutEvent timeoutEvent) { + disconnect(); } /** @@ -181,6 +183,19 @@ public class ClientCapabilities return nextCSeqValue++; } + private void disconnect() + { + + //don't alert the user if we're already off + if(provider.getRegistrarConnection().getRegistrationState().equals(RegistrationState.UNREGISTERED)) + return; + + provider.getRegistrarConnection().setRegistrationState( + RegistrationState.CONNECTION_FAILED + , RegistrationStateChangeEvent.REASON_NOT_SPECIFIED + , "A timeout occurred while trying to connect to the server."); + } + private class KeepAliveTask extends TimerTask { @@ -349,10 +364,16 @@ public class ClientCapabilities optionsTrans.sendRequest(); logger.debug("sent request= " + request); } - //we sometimes get a null pointer exception here so catch them all - catch (Exception ex) + catch (SipException ex) { - logger.error("Could not send out the register request!", ex); + logger.error("Could not send out the options request!", ex); + + if(ex.getCause() instanceof IOException) + { + // IOException problem with network + disconnect(); + } + return; } }catch(Exception ex) diff --git a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java index 886d8c7..cb5c200 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/ProtocolProviderServiceSipImpl.java @@ -2421,4 +2421,12 @@ public class ProtocolProviderServiceSipImpl { return sipStatusEnum; } + /** + * Returns the current instance of <tt>SipRegistrarConnection</tt>. + * @return SipRegistrarConnection + */ + SipRegistrarConnection getRegistrarConnection() + { + return sipRegistrarConnection; + } } diff --git a/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java b/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java index b14ad9e..f05a5dc 100644 --- a/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java +++ b/src/net/java/sip/communicator/impl/protocol/sip/SipRegistrarConnection.java @@ -720,7 +720,7 @@ public class SipRegistrarConnection * {@link RegistrationStateChangeEvent}. * @param reason a reason String further explaining the reasonCode. */ - private void setRegistrationState(RegistrationState newState, + void setRegistrationState(RegistrationState newState, int reasonCode, String reason) { |