我是靠谱客的博主 清秀微笑,最近开发中收集的这篇文章主要介绍怎么注册服务器代码,如何正确注册sip服务器?,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

// all this into a create request method

String fromName = "xxxxxxxx";

String fromSipAddress = "sip.network.com";

String toSipAddress = "sip.network.com";

String toUser = "xxxxxxxx";

SipURI fromAddress = addressFactory.createSipURI(fromName,

fromSipAddress);

Address fromNameAddress = addressFactory.createAddress(fromAddress);

FromHeader fromHeader = headerFactory.createFromHeader(

fromNameAddress, null);

SipURI toAddress = addressFactory

.createSipURI(toUser, toSipAddress);

Address toNameAddress = addressFactory.createAddress(toAddress);

ToHeader toHeader = headerFactory.createToHeader(toNameAddress,

null);

URI requestURI = addressFactory.createURI(

"sip:" + "sip.network.com");

List viaHeaders = new ArrayList();

String ipAddress = lp.getIPAddress();

ViaHeader viaHeader = headerFactory.createViaHeader(ipAddress,

lp.getPort(),

lp.getTransport(), null);

viaHeaders.add(viaHeader);

CallIdHeader callIdHeader = sipProvider.getNewCallId();

CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(1L,

Request.REGISTER);

MaxForwardsHeader maxForwards = headerFactory

.createMaxForwardsHeader(70);

Request request = messageFactory.createRequest(requestURI,

Request.REGISTER, callIdHeader, cSeqHeader, fromHeader,

toHeader, viaHeaders, maxForwards);

SipURI contactUrl = addressFactory.createSipURI(fromName, fromSipAddress);

contactUrl.setPort(8002);

contactUrl.setLrParam();

SipURI contactURI = addressFactory.createSipURI(fromName, "sip.network.com");

contactURI.setPort(sipProvider.getListeningPoint(lp.getTransport())

.getPort());

Address contactAddress = addressFactory.createAddress(contactURI);

contactHeader = headerFactory.createContactHeader(contactAddress);

request.addHeader(contactHeader);

Header extensionHeader = headerFactory.createHeader("Expires",

"120");

request.addHeader(extensionHeader);

inviteTid = sipProvider.getNewClientTransaction(request);

inviteTid.sendRequest();

Log.d("AFTERSENDREQUEST", "SipProvider = : " + sipProvider.toString());

Log.d("INVITETID", "inviteTid = " + inviteTid.getState());

dialog = inviteTid.getDialog();

}

public void processResponse(ResponseEvent responseEvent) {

Message message = Message.obtain();

message.obj = "received response "+responseEvent.getResponse();

handler.sendMessage(message);

Response response = (Response) responseEvent.getResponse();

ClientTransaction tid = responseEvent.getClientTransaction();

CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);

if (response.getStatusCode() == Response.UNAUTHORIZED){

try {

createAuthReply(authHeader, callid);

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

最后

以上就是清秀微笑为你收集整理的怎么注册服务器代码,如何正确注册sip服务器?的全部内容,希望文章能够帮你解决怎么注册服务器代码,如何正确注册sip服务器?所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部