Commit 6696f847 authored by jehan's avatar jehan

start sip proxy implementation

git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@59 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 12115d7b
......@@ -222,9 +222,44 @@ public class SipProxyRegistrar implements SipProviderListener,SipProxyRegistrarM
////Proxy methods
/////////////////////////////////////////////////////////////////////
private void proxyResponse(SipProvider aProvider, Message aMessage) throws NumberFormatException, InterruptedException, P2pProxyException, IOException {
mSuperPeerProxy.proxyResponse(aProvider, aMessage);
}
private void proxyRequest(SipProvider aProvider, Message aMessage) throws Exception {
if (aMessage.isAck() && aMessage.getToHeader().getTag() == null) {
// just terminate the Invite transaction
return;
}
if (aMessage.isInvite() == true) {
// 100 trying
TransactionServer lTransactionServer = new TransactionServer(aProvider,aMessage,null);
Message l100Trying = MessageFactory.createResponse(aMessage,100,"trying",null);
lTransactionServer.respondWith(l100Trying);
}
//remove route
MultipleHeader lMultipleRoute = aMessage.getRoutes();
if (lMultipleRoute != null) {
lMultipleRoute.removeTop();
aMessage.setRoutes(lMultipleRoute);
}
// add Via only udp
SipUtils.addVia(aProvider,aMessage);
// add recordRoute
SipUtils.addRecordRoute(aProvider,aMessage);
try {
mSuperPeerProxy.proxyRequest(aProvider, aMessage);
}catch (P2pProxyUserNotFoundException e) {
//remove via
SipUtils.removeVia(aProvider, aMessage);
if (aMessage.isInvite()) {
Message lresp = MessageFactory.createResponse(aMessage,404,e.getMessage(),null);
TransactionServer lTransactionServer = new TransactionServer(aProvider,aMessage,null);
lTransactionServer.respondWith(lresp);
} else {
throw e;
}
}
}
private void proxyRequest(SipProvider aProvider, Message aMessage) throws Exception {}
//////////////////////////////////////////////////////////////////////
......
......@@ -68,47 +68,13 @@ public class JxtaSipProxy implements SipProxy, PipeMsgListener,RegistrationHandl
mProvider = aProvider;
}
public void proxyRequest(SipProvider aProvider, Message aMessage) throws P2pProxyException {
if (aMessage.isAck() && aMessage.getToHeader().getTag() == null) {
// just terminate the Invite transaction
return;
}
if (aMessage.isInvite() == true) {
// 100 trying
TransactionServer lTransactionServer = new TransactionServer(aProvider,aMessage,null);
Message l100Trying = MessageFactory.createResponse(aMessage,100,"trying",null);
lTransactionServer.respondWith(l100Trying);
}
String lTo = aMessage.getToHeader().getNameAddress().getAddress().toString();
//remove route
MultipleHeader lMultipleRoute = aMessage.getRoutes();
if (lMultipleRoute != null) {
lMultipleRoute.removeTop();
aMessage.setRoutes(lMultipleRoute);
}
// add Via only udp
SipUtils.addVia(aProvider,aMessage);
// add recordRoute
SipUtils.addRecordRoute(aProvider,aMessage);
try {
mSdpProcessor.processSdpBeforeSendingToPipe(aMessage);
// proxy message to pipe
OutputPipe lOutputPipe = sendMessageToPipe(lTo,aMessage.toString());
mSdpProcessor.processSdpAfterSentToPipe( aMessage,lOutputPipe);
} catch (P2pProxyUserNotFoundException e) {
//remove via
SipUtils.removeVia(aProvider, aMessage);
if (aMessage.isInvite()) {
Message lresp = MessageFactory.createResponse(aMessage,404,e.getMessage(),null);
TransactionServer lTransactionServer = new TransactionServer(aProvider,aMessage,null);
lTransactionServer.respondWith(lresp);
} else {
throw e;
}
} catch (Exception e2) {
} catch (Exception e2) {
//remove via
SipUtils.removeVia(aProvider, aMessage);
throw new P2pProxyException(e2);
......
......@@ -19,25 +19,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.p2pproxy.core.sipproxy.superpeers;
import java.util.Map;
import org.linphone.p2pproxy.api.P2pProxyException;
import org.linphone.p2pproxy.core.JxtaNetworkManager;
import org.linphone.p2pproxy.core.sipproxy.RegistrationHandler;
import org.linphone.p2pproxy.core.sipproxy.SipProxy;
import org.linphone.p2pproxy.core.sipproxy.SipProxyRegistrar.Registration;
import org.zoolu.sip.address.SipURL;
import org.zoolu.sip.message.Message;
import org.zoolu.sip.provider.SipProvider;
public class SuperPeerProxy implements SipProxy, RegistrationHandler {
private final JxtaNetworkManager mJxtaNetworkManager;
private final String mRegistrarAddress;
private final Map<String,Registration> mRegistrationTab;
public SuperPeerProxy(JxtaNetworkManager aJxtaNetworkManager, String aRegistrarAddress) {
public SuperPeerProxy(JxtaNetworkManager aJxtaNetworkManager, String aRegistrarAddress, Map<String,Registration> aRegistrationTab ) {
mJxtaNetworkManager = aJxtaNetworkManager;
mRegistrarAddress = aRegistrarAddress;
mRegistrationTab = aRegistrationTab;
}
public void proxyRequest(SipProvider provider, Message message) throws P2pProxyException {
// TODO Auto-generated method stub
// 1 check if user is a local user
}
......
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