SIP IM client

"Quintus Kahapolarachchi" <[email protected]>
Newsgroups gmane.comp.voip.nist-sip
Message-ID <[email protected]>
Hi,

I am trying to develop an IM client based on SIP and Java. Since I was unsuccessful in finding a good tutorial regarding this field, I am trying the trial-and-error approach.

I have a SIP-proxy (Based on OpenSER), and what I am trying to create is a client who will connect and stay connected to this server and hopefully print out the messages.

So for starters I tried to send a <REGISTER> command to the server with my login and password, but all I getin my command prompt is <null>.

Can someone please give me a push on the right direction?

Thank you
Quintus





-------------------- CODE -------------------------
import javax.sip.SipListener;
import java.io.*;
import javax.sip.*;
import javax.sip.address.*;
import javax.sip.header.*;
import javax.sip.message.*;
import java.util.*;
import gov.nist.javax.sip.address.*;
import gov.nist.javax.sip.header.*;
import java.lang.Object;


public class sipClient implements SipListener {
	Properties properties = new Properties();
	SipStack sipStack = null;
	SipFactory sipFactory = null;
	SipProvider sipProvider = null;
	AddressFactoryImpl addressFactoryImpl = null;
	Address address = null;
	SipURI sipURI = null;
	Request request = null;
	MessageFactory messageFactory = null;
	AddressFactory addressFactory = null;
	CallIdHeader callIdHeader = null;
	CSeqHeader cSeqHeader = null;
	FromHeader fromHeader = null;
	ToHeader toHeader = null; 
	ClientTransaction clientTransaction = null;
	
	public sipClient(){
		try{
			properties.setProperty("javax.sip.IP_ADDRESS", "127.0.0.1");
			properties.setProperty("javax.sip.OUTBOUND_PROXY", "192.168.1.99:5070/UDP");
			sipStack = sipFactory.createSipStack(properties);
			sipURI.setHost("192.168.1.99");
			sipURI.setPort(5070);
			sipURI.setUser("xTrade Client");
			sipURI.setUserPassword("123");
			//sipURI = addressFactory.createSipURI("100", "127.0.0.1");
			callIdHeader.setCallId("Xtrade");
			cSeqHeader.setSequenceNumber(4371);
			address.setDisplayName("JAG");
			fromHeader.setAddress(address);
			Address add = null;
			add.setURI(sipURI);
			toHeader.setAddress(add);
			List viaHeadersList = new ArrayList();
			ViaHeader viaHeaders = null;
			viaHeaders.setProtocol("SIP/2.0");
			viaHeaders.setHost("192.168.1.99");
			viaHeaders.setPort(5070);
			viaHeadersList.add(viaHeaders);
			MaxForwards maxForwards = new MaxForwards();
			maxForwards.setMaxForwards(70);
			SipURI requestURI = addressFactory.createSipURI("100", "127.0.0.1");
			//request = messageFactory.createRequest(Request.REGISTER);
			//request = messageFactory.createRequest(requestURI, method, callId, cSeq, from, to, via, maxForwards, contentType, content);
			request = messageFactory.createRequest(requestURI, Request.REGISTER, callIdHeader,cSeqHeader, fromHeader, toHeader, viaHeadersList, maxForwards);
			clientTransaction = sipProvider.getNewClientTransaction(request);
			clientTransaction.sendRequest();
		}catch(Exception e){
			System.err.println(e.getMessage());
		}
	}
	public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent){
		
	}
	public void processIOException(IOExceptionEvent exceptionEvent){
		System.out.println(exceptionEvent.toString());
	}
	public void processRequest(RequestEvent requestEvent){
		
	}
	public void processResponse(ResponseEvent responseEvent){
		
	}
	public void processTimeout(TimeoutEvent timeoutEvent){
		
	}
	public void processTransactionTerminated(TransactionTerminatedEvent transactionTerminatedEvent){
		
	}
	public static void main(String [] args){
		sipClient sc = new sipClient();
	}
}

_______________________________________________
nist-sip mailing list
[email protected]
http://www-x.antd.nist.gov/mailman/listinfo/nist-sip
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.