Commit e26116b7 authored by jehan's avatar jehan

one more step for fonis ;-)

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@127 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent ada8ab24
......@@ -24,6 +24,7 @@ package org.linphone.p2pproxy.core.sipproxy;
import java.io.File;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Timer;
......@@ -82,6 +83,7 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
private long mNumberOfUnknownUsersForRegistration;
private long mNumberOfUnRegistration;
public static class Registration {
long RegistrationDate;
public long Expiration;
......@@ -190,6 +192,23 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
};
mTimer.scheduleAtFixedRate(lPublisherTask, 0, ADV_LIFE_TIME-ADV_LIFE_TIME/10);
TimerTask lRegistrationTableGC = new TimerTask() {
@Override
public void run() {
// copy list
Collection<Registration> lCurrentRegistrations = mRegistrationTab.values();
long lCurrentDate = System.currentTimeMillis();
for (Registration lRegistration : lCurrentRegistrations) {
if ((lCurrentDate - lRegistration.RegistrationDate - lRegistration.Expiration) > 0) {
if (mLog.isInfoEnabled()) mLog.info("registration entry ["+lRegistration+"] has expired");
mRegistrationTab.remove(lRegistration.From);
}
}
}
};
mTimer.scheduleAtFixedRate(lRegistrationTableGC, 0, 60000);
}
public void onReceivedMessage(SipProvider aProvider, Message aMessage) {
......
......@@ -58,7 +58,7 @@ public class JxtaNetworkResources {
} catch (IOException e1) {
throw new P2pProxyException(e1);
}
mLog.debug("publishing P2pUserRegistration Advertisement ["+mP2pUserRegistrationAdvertisement+"]published expire ["+aLiveTime+"]");
mLog.info("publishing P2pUserRegistration Advertisement ["+mP2pUserRegistrationAdvertisement+"]published expire ["+aLiveTime+"]");
}
}
......@@ -99,7 +99,7 @@ public class P2pUserRegistrationAdvertisement extends ExtendableAdvertisement im
private String mRegistrarAddress;
private String mUserUri;
public final static String REGISTRAR_ADDRESS_TAG = "registrar-address";
public final static String USER_NAME_TAG = "user-name";
public final static String USER_NAME_TAG = "registration-user-name";
private final static String ID_TAG = "ID";
private final static String[] mIndexs = {USER_NAME_TAG};
private final static Logger mLog = Logger.getLogger(P2pUserRegistrationAdvertisement.class);
......
......@@ -19,6 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.p2pproxy.core.sipproxy.superpeers;
import java.io.IOException;
import java.util.List;
import java.util.Map;
......@@ -26,6 +28,7 @@ import org.apache.log4j.Logger;
import org.linphone.p2pproxy.api.P2pProxyException;
import org.linphone.p2pproxy.api.P2pProxyUserNotFoundException;
import org.linphone.p2pproxy.core.JxtaNetworkManager;
import org.linphone.p2pproxy.core.P2pProxyAdvertisementNotFoundException;
import org.linphone.p2pproxy.core.sipproxy.RegistrationHandler;
import org.linphone.p2pproxy.core.sipproxy.SipProxy;
import org.linphone.p2pproxy.core.sipproxy.SipUtils;
......@@ -66,7 +69,16 @@ public class SuperPeerProxy implements SipProxy, RegistrationHandler {
//great, just need to get it
lNextHope = new SipURL(mRegistrationTab.get(lTo).Contact);
} else {
throw new P2pProxyUserNotFoundException("user ["+lTo+"] not found");
if (aMessage.isInvite() || aMessage.isCancel()) {
//need to found the right proxy
try {
List<P2pUserRegistrationAdvertisement> lAdvList = (List<P2pUserRegistrationAdvertisement>) mJxtaNetworkManager.getAdvertisementList(null, P2pUserRegistrationAdvertisement.USER_NAME_TAG,lTo, true);
lNextHope = new SipURL(lAdvList.get(0).getUserName());
} catch (Exception e) {
throw new P2pProxyUserNotFoundException("user ["+lTo+"] not found",e);
}
}
}
}
if (aMessage.isInvite() || aMessage.isCancel()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment