当前位置: 首页>>代码示例>>Java>>正文


Java FromHeader类代码示例

本文整理汇总了Java中javax.sip.header.FromHeader的典型用法代码示例。如果您正苦于以下问题:Java FromHeader类的具体用法?Java FromHeader怎么用?Java FromHeader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FromHeader类属于javax.sip.header包,在下文中一共展示了FromHeader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHeadersToOmmitOnResponseCopy

import javax.sip.header.FromHeader; //导入依赖的package包/类
private static Set<String> getHeadersToOmmitOnResponseCopy() {
	if (HEADERS_TO_OMMIT_ON_RESPONSE_COPY == null) {
		final Set<String> set = new HashSet<String>();
		set.add(RouteHeader.NAME);
		set.add(RecordRouteHeader.NAME);
		set.add(ViaHeader.NAME);
		set.add(CallIdHeader.NAME);
		set.add(CSeqHeader.NAME);
		set.add(ContactHeader.NAME);
		set.add(FromHeader.NAME);
		set.add(ToHeader.NAME);
		set.add(ContentLengthHeader.NAME);
		HEADERS_TO_OMMIT_ON_RESPONSE_COPY = Collections.unmodifiableSet(set);
	}
	return HEADERS_TO_OMMIT_ON_RESPONSE_COPY;
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:17,代码来源:TestCall.java

示例2: sendMultipleContactRegistration

import javax.sip.header.FromHeader; //导入依赖的package包/类
public void sendMultipleContactRegistration() throws Exception {
     	Address fromAddress = addressFactory.createAddress("[email protected]:5070");
     	ContactHeader contactHeader1 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5070"));
 		ContactHeader contactHeader2 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5080"));
 		
 		
CallIdHeader callId = provider.getNewCallId();			
CSeqHeader cSeq = headerFactory.createCSeqHeader(1l, Request.REGISTER);
FromHeader from = headerFactory.createFromHeader(fromAddress, "1234");
ToHeader to = headerFactory.createToHeader(addressFactory.createAddress("[email protected]"+host+":"+SERVER_PORT), null);
List via = Arrays.asList(((ListeningPointImpl)provider.getListeningPoint(testProtocol)).getViaHeader());			
MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(10);
 		
 		URI requestURI = addressFactory.createURI("sip:[email protected]"+host+":"+SERVER_PORT);
 		Request request = messageFactory.createRequest(requestURI, Request.REGISTER, callId, cSeq, from, to, via, maxForwards);
 		    		
 		request.setRequestURI(requestURI);
 		request.addHeader(contactHeader1);
 		request.addHeader(contactHeader2);
 		ClientTransaction ctx = this.provider.getNewClientTransaction(request);
 		ctx.sendRequest();
     }
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:23,代码来源:MultipleContactsTest.java

示例3: sendInviteWithRPort

import javax.sip.header.FromHeader; //导入依赖的package包/类
public void sendInviteWithRPort() throws Exception {
     	Address fromAddress = addressFactory.createAddress("[email protected]:5070");
     	ContactHeader contactHeader1 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5070"));
 		ContactHeader contactHeader2 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5080"));
 		
 		
CallIdHeader callId = provider.getNewCallId();			
CSeqHeader cSeq = headerFactory.createCSeqHeader(1l, Request.INVITE);
FromHeader from = headerFactory.createFromHeader(fromAddress, "1234");
ToHeader to = headerFactory.createToHeader(addressFactory.createAddress("[email protected]"+host+":"+SERVER_PORT), null);
ViaHeader via = ((ListeningPointImpl)provider.getListeningPoint(testProtocol)).getViaHeader();
via.setRPort();
List vias = Arrays.asList(via);			
MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(10);
 		
 		URI requestURI = addressFactory.createURI("sip:[email protected]"+host+":"+SERVER_PORT);
 		Request request = messageFactory.createRequest(requestURI, Request.INVITE, callId, cSeq, from, to, vias, maxForwards);
 		System.out.println(request);
 		assertTrue(request.toString().indexOf("rport=") == -1);    		
 		
 		request.setRequestURI(requestURI);
 		request.addHeader(contactHeader1);
 		request.addHeader(contactHeader2);
 		ClientTransaction ctx = this.provider.getNewClientTransaction(request);
 		ctx.sendRequest();
     }
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:27,代码来源:ViaRPortTest.java

示例4: getAddress

import javax.sip.header.FromHeader; //导入依赖的package包/类
public String getAddress() {
    if (dialog.getState() != null) {
        return dialog.getRemoteParty().getURI().toString();
    }
    else {
        if (dialog.isServer()) {
            FromHeader fromHeader = (FromHeader)initialRequest
                    .getHeader(FromHeader.NAME);
            return fromHeader.getAddress().getURI().toString();
        }
        else {
            ToHeader toHeader = (ToHeader)initialRequest
                    .getHeader(ToHeader.NAME);
            return toHeader.getAddress().getURI().toString();
        }
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:18,代码来源:Call.java

示例5: processRegister

import javax.sip.header.FromHeader; //导入依赖的package包/类
public void processRegister(RequestEvent requestEvent,
                                ServerTransaction serverTransactionId) {
        Request request = requestEvent.getRequest();
        ContactHeader contact = (ContactHeader) request.getHeader(ContactHeader.NAME);
        SipURI contactUri = (SipURI) contact.getAddress().getURI();
        FromHeader from = (FromHeader) request.getHeader(FromHeader.NAME);
        SipURI fromUri = (SipURI) from.getAddress().getURI();

//        DataServer.getUserData().setContact(fromUri.toString(),
//                new UserData.UserAddress(contactUri.getHost(),contactUri.getPort()));

        // Verify AUTHORIZATION !!!!!!!!!!!!!!!!


        try {
            DigestServerAuthenticationWWWHelper dsam = new DigestServerAuthenticationWWWHelper();

            if (!dsam.doAuthenticatePlainTextPassword(request, DataServer.getUserData().getPassword(fromUri.getUser()))) {
                Response challengeResponse = mMessageFactory.createResponse(
                        Response.UNAUTHORIZED, request);
                dsam.generateChallenge(mHeaderFactory, challengeResponse, "nist.gov");
                mSipProvider.getNewServerTransaction(request).sendResponse(challengeResponse);
                return;

            }

            Response response = mMessageFactory.createResponse(Response.OK, request);
            ServerTransaction serverTransaction = mSipProvider.getNewServerTransaction(request);
            serverTransaction.sendResponse(response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:34,代码来源:SipServer.java

示例6: processInvite

import javax.sip.header.FromHeader; //导入依赖的package包/类
/**
 * Process the invite request.
 */
public void processInvite(RequestEvent requestEvent,
        ServerTransaction serverTransaction) {
    SipProvider sipProvider = (SipProvider) requestEvent.getSource();
    Request request = requestEvent.getRequest();
    try {


        Response okResponse = messageFactory.createResponse(Response.OK,
                request);
        FromHeader from = (FromHeader) okResponse.getHeader(FromHeader.NAME);
        from.removeParameter("tag");
        Address address = addressFactory.createAddress("Shootme <sip:"
                + myAddress + ":" + myPort + ">");
        ContactHeader contactHeader = headerFactory
                .createContactHeader(address);
        ToHeader toHeader = (ToHeader) okResponse.getHeader(ToHeader.NAME);
        toHeader.setTag("4321"); // Application is supposed to set.
        okResponse.addHeader(contactHeader);
        sipProvider.sendResponse(okResponse); // Send it through the Provider.


    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:30,代码来源:RejectInvalidResponseTest.java

示例7: MakeRequest

import javax.sip.header.FromHeader; //导入依赖的package包/类
/**
 * 
 * @param sipManager - SipManager object
 * @param to - To identifies receiver IP
 * @param message Message that should be send
 * @return Return SIP Message.
 * @throws ParseException
 * @throws InvalidArgumentException
 */
public Request MakeRequest(SipManager sipManager, String to, String message) throws ParseException, InvalidArgumentException {
	AddressFactory addressFactory = sipManager.addressFactory;
	sipManager.setCseqNumber((long)sipManager.getCseqNumber()+1l);
	Address fromNameAddress = addressFactory.createAddress("sip:"+ SipManager.sipUserName + "@"+ SipManager.registrarIp);
	FromHeader fromHeader = sipManager.headerFactory.createFromHeader(fromNameAddress, "SyMPHOnY");
	URI toAddress = sipManager.addressFactory.createURI(to);
	Address toNameAddress = sipManager.addressFactory.createAddress(toAddress);
	ToHeader toHeader = sipManager.headerFactory.createToHeader(toNameAddress, null);
	URI requestURI = sipManager.addressFactory.createURI(to);
	ArrayList<ViaHeader> viaHeaders = sipManager.createViaHeader();
	CallIdHeader callIdHeader = sipManager.sipProvider.getNewCallId();
	CSeqHeader cSeqHeader = sipManager.headerFactory.createCSeqHeader(sipManager.getCseqNumber(),Request.MESSAGE);
	MaxForwardsHeader maxForwards = sipManager.headerFactory
			.createMaxForwardsHeader(70);
	Request request = sipManager.messageFactory.createRequest(requestURI,
			Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
			toHeader, viaHeaders, maxForwards);
	SupportedHeader supportedHeader = sipManager.headerFactory
			.createSupportedHeader("replaces, outbound");
	request.addHeader(supportedHeader);
	SipURI routeUri = sipManager.addressFactory.createSipURI(null,
			SipManager.proxyIp);
	routeUri.setTransportParam(SipManager.transport);
	routeUri.setLrParam();
	routeUri.setPort(SipManager.proxyPort);

	Address routeAddress = sipManager.addressFactory
			.createAddress(routeUri);
	RouteHeader route = sipManager.headerFactory
			.createRouteHeader(routeAddress);
	request.addHeader(route);
	ContentTypeHeader contentTypeHeader = sipManager.headerFactory
			.createContentTypeHeader("text", "plain");
	request.setContent(message, contentTypeHeader);
	System.out.println(request);
	return request;

}
 
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:48,代码来源:MessageMessage.java

示例8: getFrom

import javax.sip.header.FromHeader; //导入依赖的package包/类
public final String getFrom()
{
	FromHeader header = (FromHeader) request.getHeader(FromHeader.NAME);
	if (header == null)
		return "null";
	return header.getAddress().toString();
}
 
开发者ID:lmangani,项目名称:Reaper,代码行数:8,代码来源:RequestMessage.java

示例9: handleRequest

import javax.sip.header.FromHeader; //导入依赖的package包/类
public void handleRequest(RequestEvent requestEvent) {
	Request request = requestEvent.getRequest();
	String method = ((CSeqHeader) request.getHeader(CSeqHeader.NAME))
			.getMethod();
	if (method.equals(Request.INVITE)) {
		FromHeader fromHeader =  (FromHeader)request.getHeader(FromHeader.NAME);
		recipient = fromHeader.getAddress().toString();
		remoteHost = ((SipURI)fromHeader.getAddress().getURI()).getHost();
		sipHandler.setRemoteHost(remoteHost);
		sendInviteReply(requestEvent);
	} else if (method.equals (Request.BYE)) {
		hangup();
	}
}
 
开发者ID:davidrudder23,项目名称:OpenNotification,代码行数:15,代码来源:SipInboundCall.java

示例10: getRemoteName

import javax.sip.header.FromHeader; //导入依赖的package包/类
public String getRemoteName() {
    Address address;
    if (dialog.getState() != null) {
        address = dialog.getRemoteParty();
    }
    else {
        if (dialog.isServer()) {
            FromHeader fromHeader = (FromHeader)initialRequest
                    .getHeader(FromHeader.NAME);
            address = fromHeader.getAddress();
        }
        else {
            ToHeader toHeader = (ToHeader)initialRequest
                    .getHeader(ToHeader.NAME);
            address = toHeader.getAddress();
        }
    }
    String retVal = null;
    if (address.getDisplayName() != null
            && address.getDisplayName().trim().length() > 0) {
        retVal = address.getDisplayName();
    }
    else {
        URI uri = address.getURI();
        if (uri.isSipURI()) {
            retVal = ((SipURI)uri).getUser();
        }
    }
    return retVal == null ? "" : retVal;
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:31,代码来源:Call.java

示例11: getFromHeader

import javax.sip.header.FromHeader; //导入依赖的package包/类
public FromHeader getFromHeader(boolean isNew)
        throws CommunicationsException {

    if (fromHeader != null && !isNew) {
        return fromHeader;
    }
    try {
        SipURI fromURI = (SipURI) addressFactory
                .createURI(currentlyUsedURI);

        fromURI.setTransportParam(listeningPoint.getTransport());

        fromURI.setPort(listeningPoint.getPort());
        Address fromAddress = addressFactory.createAddress(fromURI);
        if (displayName != null && displayName.trim().length() > 0) {
            fromAddress.setDisplayName(displayName);
        } else {
            fromAddress
                    .setDisplayName(Credentials.getUserDisplay());
        }
        fromHeader = headerFactory.createFromHeader(fromAddress,
                Integer.toString(hashCode()));

    }
    catch (ParseException ex) {
        throw new CommunicationsException(
                "A ParseException occurred while creating From Header!",
                ex);
    }
    return fromHeader;
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:32,代码来源:SipManager.java

示例12: getFromAddress

import javax.sip.header.FromHeader; //导入依赖的package包/类
public String getFromAddress() {
    Request request = (Request)getSource();
    String fromAddress = "<unknown>";
    try {
        FromHeader fromHeader = (FromHeader)request
                .getHeader(FromHeader.NAME);
        fromAddress = fromHeader.getAddress().getURI().toString();
    }
    catch (NullPointerException exc) {
        // Noone wants to know about ou null pointer exception

    }
    return fromAddress;
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:15,代码来源:MessageEvent.java

示例13: getFromName

import javax.sip.header.FromHeader; //导入依赖的package包/类
public String getFromName() {
    Request request = (Request)getSource();
    String fromName = null;
    try {
        FromHeader fromHeader = (FromHeader)request
                .getHeader(FromHeader.NAME);
        fromName = fromHeader.getAddress().getDisplayName();
    }
    catch (NullPointerException exc) {
        // Noone wants to know about ou null pointer exception

    }
    return fromName == null ? "<unknown>" : fromName;
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:15,代码来源:MessageEvent.java

示例14: processTimeout

import javax.sip.header.FromHeader; //导入依赖的package包/类
void processTimeout(Transaction transaction, Request request) {
    System.err.println("TIME ERROR");
    isRegistered = true;
    FromHeader fromHeader = ((FromHeader) request.getHeader(FromHeader.NAME));
    Address address = fromHeader.getAddress();
    sipManCallback.fireRegistrationFailed("Unable to register with " + address.toString(), RegistrationEvent.Type.TimeOut);
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:8,代码来源:RegisterProcessing.java

示例15: processNotImplemented

import javax.sip.header.FromHeader; //导入依赖的package包/类
void processNotImplemented(ClientTransaction transatcion, Response response) {
    isRegistered = true;
    FromHeader fromHeader = ((FromHeader) response
            .getHeader(FromHeader.NAME));
    Address address = fromHeader.getAddress();
    sipManCallback.fireUnregistered("Server returned NOT_IMPLEMENTED. "
            + address.toString());
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:9,代码来源:RegisterProcessing.java


注:本文中的javax.sip.header.FromHeader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。