diff --git a/p2pproxy/src/org/linphone/p2pproxy/api/P2pProxyResourceManagement.java b/p2pproxy/src/org/linphone/p2pproxy/api/P2pProxyResourceManagement.java index e2fe356b0..44f11504d 100644 --- a/p2pproxy/src/org/linphone/p2pproxy/api/P2pProxyResourceManagement.java +++ b/p2pproxy/src/org/linphone/p2pproxy/api/P2pProxyResourceManagement.java @@ -22,7 +22,8 @@ package org.linphone.p2pproxy.api; public interface P2pProxyResourceManagement { - /** + public final String DOMAINE="p2p.linphone.org"; + /** * * @return the SIP uri of an available sip proxy registrar for a given domaine */ diff --git a/p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyMain.java b/p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyMain.java index fbc1dd614..ca91acb46 100644 --- a/p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyMain.java +++ b/p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyMain.java @@ -318,6 +318,17 @@ public class P2pProxyMain implements P2pProxyMainMBean { mP2pProxyManagement = (P2pProxyManagement) mServiceProvider; mP2pProxySipProxyRegistrarManagement = (P2pProxyResourceManagement) mServiceProvider; mServiceProvider.start(3000L); +// setup sip provider + SipStack.log_path = mConfigHomeDir+"/logs"; + mSipAndPipeListener = new SipProxyRegistrar(mConfigurator,mJxtaNetworkManager,mP2pProxyAccountManagement); + //set management + try { + ObjectName lObjectName = new ObjectName(PROXY_REG_MBEAN_NAME); + ManagementFactory.getPlatformMBeanServer().registerMBean(mSipAndPipeListener,lObjectName); + + } catch (Exception e) { + mLog.warn("cannot register MBean",e); + } } private static void startSeeding(Configurator aProperties,File aConfigDir) throws Exception{ // setup jxta @@ -326,6 +337,17 @@ public class P2pProxyMain implements P2pProxyMainMBean { mP2pProxyManagement = null; mP2pProxySipProxyRegistrarManagement = (P2pProxyResourceManagement) mServiceProvider; mServiceProvider.start(3000L); +// setup sip provider + SipStack.log_path = mConfigHomeDir+"/logs"; + mSipAndPipeListener = new SipProxyRegistrar(mConfigurator,mJxtaNetworkManager,mP2pProxyAccountManagement); + //set management + try { + ObjectName lObjectName = new ObjectName(PROXY_REG_MBEAN_NAME); + ManagementFactory.getPlatformMBeanServer().registerMBean(mSipAndPipeListener,lObjectName); + + } catch (Exception e) { + mLog.warn("cannot register MBean",e); + } } private static void usage() { System.out.println("p2pproxy"); diff --git a/p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyResourceManagementImpl.java b/p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyResourceManagementImpl.java index cecaff481..998acdcbb 100644 --- a/p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyResourceManagementImpl.java +++ b/p2pproxy/src/org/linphone/p2pproxy/core/P2pProxyResourceManagementImpl.java @@ -8,7 +8,7 @@ import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrar; public class P2pProxyResourceManagementImpl implements P2pProxyResourceManagement { protected final JxtaNetworkManager mJxtaNetworkManager; - private final String DOMAINE="p2p.linphone.org"; + private final static Logger mLog = Logger.getLogger(P2pProxyResourceManagementImpl.class); P2pProxyResourceManagementImpl(JxtaNetworkManager aJxtaNetworkManager) { mJxtaNetworkManager = aJxtaNetworkManager; diff --git a/p2pproxy/test-src/org/linphone/p2pproxy/test/utils/UserInstance.java b/p2pproxy/test-src/org/linphone/p2pproxy/test/utils/UserInstance.java new file mode 100644 index 000000000..a689cf899 --- /dev/null +++ b/p2pproxy/test-src/org/linphone/p2pproxy/test/utils/UserInstance.java @@ -0,0 +1,91 @@ +/* +p2pproxy +Copyright (C) 2007 Jehan Monnier () + +P2pAutoConfigTester.java - . + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ +package org.linphone.p2pproxy.test.utils; + +import java.io.File; +import java.net.DatagramSocket; +import java.util.Timer; +import java.util.TimerTask; + +import org.linphone.p2pproxy.api.P2pProxyException; +import org.linphone.p2pproxy.api.P2pProxyResourceManagement; +import org.linphone.p2pproxy.core.P2pProxyMain; +import org.linphone.p2pproxy.launcher.P2pProxylauncherConstants; +import org.zoolu.net.SocketAddress; +import org.zoolu.sip.provider.SipProvider; +import org.zoolu.sip.provider.SipStack; + +public class UserInstance { +private final Thread mFonisThread; +private Timer mTimer; +private final SipProvider mProvider; +private final SipClient mSipClient; + + +public UserInstance(final String userName) throws P2pProxyException { + try { + DatagramSocket lSocket = new DatagramSocket(); + lSocket.setReuseAddress(true); + int lSipPort = lSocket.getLocalPort(); + lSocket.close(); + final String[] lParam = {"-jxta userinstance-"+userName + ," -edge-only" + ," -seeding-rdv tcp://82.67.74.86:9701" + ," -seeding-relay tcp://82.67.74.86:9701"}; + lSocket.close(); + + Runnable lFonisTask = new Runnable() { + public void run() { + P2pProxyMain.main(lParam); + } + + }; + mFonisThread = new Thread(lFonisTask,"fonis lib"); + mFonisThread.start(); + int lRetry=0; + while (P2pProxyMain.getState() != P2pProxylauncherConstants.P2PPROXY_CONNECTED && lRetry++<20) { + Thread.sleep(500); + } + if (P2pProxyMain.getState() != P2pProxylauncherConstants.P2PPROXY_CONNECTED) { + throw new P2pProxyException("Cannot connect to fonis network"); + } + P2pProxyMain.createAccount(userName); + SipStack.log_path = "userinstance-"+userName+"/logs"; + File lFile = new File(SipStack.log_path); + if (lFile.exists() == false) lFile.mkdir(); + mProvider=new SipProvider(null,lSipPort); + mSipClient = new SipClient(mProvider,userName,30000); + TimerTask lTimerTask = new TimerTask() { + @Override + public void run() { + // 1 get proxy address + String lProxyUri = P2pProxyMain.lookupSipProxyUri(P2pProxyResourceManagement.DOMAINE); + //2 setOutbound proxy + mProvider.setOutboundProxy(new SocketAddress(lProxyUri)); + + } + + }; + } catch (Exception e) { + throw new P2pProxyException("cannot start client",e); + } +} +}