亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? presentitymanager.java

?? 是一個(gè)用java實(shí)現(xiàn)的
?? JAVA
字號(hào):
/*
 * PresentityManager.java
 * 
 * Created on Mar 22, 2004
 *
 */
package gov.nist.applet.phone.ua.presence;

import gov.nist.applet.phone.ua.Configuration;
import gov.nist.applet.phone.ua.MessageListener;
import gov.nist.applet.phone.ua.MessengerManager;
import gov.nist.applet.phone.ua.pidf.parser.XMLpidfParser;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;

import javax.sip.ClientTransaction;
import javax.sip.Dialog;
import javax.sip.InvalidArgumentException;
import javax.sip.ListeningPoint;
import javax.sip.ServerTransaction;
import javax.sip.SipException;
import javax.sip.address.Address;
import javax.sip.address.AddressFactory;
import javax.sip.address.SipURI;
import javax.sip.header.CSeqHeader;
import javax.sip.header.CallIdHeader;
import javax.sip.header.ContentTypeHeader;
import javax.sip.header.ExpiresHeader;
import javax.sip.header.FromHeader;
import javax.sip.header.Header;
import javax.sip.header.HeaderFactory;
import javax.sip.header.MaxForwardsHeader;
import javax.sip.header.RouteHeader;
import javax.sip.header.ToHeader;
import javax.sip.header.ViaHeader;
import javax.sip.message.MessageFactory;
import javax.sip.message.Request;
import javax.sip.message.Response;

/**
 * This class manage the presence of the application, i.e subscriptions and 
 * notifications
 * 
 * @author Jean Deruelle <jean.deruelle@nist.gov>
 *
 * <a href="{@docRoot}/uncopyright.html">This code is in the public domain.</a>
 */
public class PresentityManager {
	private Hashtable subscriberList = null;
	private MessengerManager sipMeetingManager=null;
	private MessageListener messageListener=null;
	private Configuration configuration=null;
	/**
	 * 
	 */
	public PresentityManager(MessengerManager sipMeetingManager) {
		subscriberList=new Hashtable();	
		this.sipMeetingManager=sipMeetingManager;
		this.messageListener=sipMeetingManager.getMessageListener();
		this.configuration=this.messageListener.getConfiguration();
	}

	/**
	 * Retrieve a subscriber by his address
	 * @param subscriberAddress - the subscriber address
	 * @return the subscriber
	 */
	public Subscriber getSubscriber(String subscriberAddress){
		return (Subscriber)subscriberList.get(subscriberAddress);
	}
	
	/**
	 * Add a subscriber to our subscriber list
	 * @param subscriber - subscriber to add
	 */
	public void addSubscriber(Subscriber subscriber){
		Subscriber subscriberFromList=
			(Subscriber)subscriberList.get(subscriber.getAddress());
		if(subscriberFromList==null)
			subscriberList.put(subscriber.getAddress(),subscriber);
		else{
			System.out.println("Already in list put the dialog to"+
				subscriber.getDialog());
			subscriberFromList.setDialog(subscriber.getDialog());			
		}
		System.out.println(subscriber.getAddress()+" has been added to your contacts.");
		System.out.println(subscriber.getDialog());
	}

	/**
	 * Remove a subscriber to our subscriber list
	 * @param subscriber - subscriber to remove
	 */
	public void removeSubscriber(String subscriber){		
		subscriberList.remove(subscriber);
		System.out.println(subscriber+" has been removed from your contacts.");
	}	

	/**
	 * The user has accepted to add the contact to his contact list
	 * So we send an ok
	 * @param subscriber - the subscriber for who we are going to send an ok
	 */
	public void acceptSubscribe(String subscriberAddress){
		Subscriber subscriber=(Subscriber)subscriberList.get(subscriberAddress);
		Dialog dialog=subscriber.getDialog();
		if (!dialog.isServer()) {
			System.out.println("Problem : it's a client transaction");            
		}
		ServerTransaction serverTransaction=
			(ServerTransaction) dialog.getFirstTransaction();
		Request request=serverTransaction.getRequest();
		Response response=null;
		try{
			response=MessageListener.messageFactory.createResponse(Response.OK,request);
			ToHeader toHeader=(ToHeader)response.getHeader(ToHeader.NAME);
			if (toHeader.getTag()==null)
				toHeader.setTag(new Integer((int)(Math.random() * 10000)).toString());
		}
		catch(ParseException pe){
			pe.printStackTrace();
		}
		try{
			serverTransaction.sendResponse(response);
		}
		catch(SipException se){
			se.printStackTrace();
		}
		messageListener.sipMeetingManager.getPresentityManager().
			sendNotifyToSubscriber(
									subscriber,
									"open",
									"online");
	}

	/**
	 * The user has declined to add the contact to his contact list
	 * So we send a DECLINE
	 * @param subscriber - the subscriber for who we are going to send an DECLINE
	 */    
	public void declineSubscribe(String subscriberAddress){
		Subscriber subscriber=(Subscriber)subscriberList.get(subscriberAddress);
		Dialog dialog=subscriber.getDialog();
		if (!dialog.isServer()) {
			System.out.println("Problem : it's a client transaction");            
		}
		ServerTransaction serverTransaction=
			(ServerTransaction) dialog.getFirstTransaction();
		Request request=serverTransaction.getRequest();
		Response response=null;
		try{
			response=MessageListener.messageFactory.createResponse(Response.DECLINE,request);
		}
		catch(ParseException pe){
			pe.printStackTrace();
		}
		try{
			serverTransaction.sendResponse(response);
		}
		catch(SipException se){
			se.printStackTrace();
		}
		subscriberList.remove(subscriber.getAddress());
	}

	/**
	 * Send a notification of the presence status of the application to all 
	 * subscribers
	 * @param status - status of the presence
	 * @param subStatus - subStatus of the presence
	 */
	public void sendNotifyToAllSubscribers(String status,String subStatus) {
		try{
			 // We have to get all our subscribers and send them a NOTIFY!
			 System.out.println("DEBUG, IMNotifyProcessing, sendNotifyToAllSuscribers(),"+
			 " we have to notify our SUBSCRIBERS: let's send a NOTIFY for each one "+
			 "of them (subscribersList: "+subscriberList.size()+")!!!");
			Enumeration e=subscriberList.elements();
			while(e.hasMoreElements()) {
				Subscriber subscriber=(Subscriber)e.nextElement();                
				String subscriberName=subscriber.getAddress();
            
				String contactAddress= configuration.contactIPAddress+":"+
					configuration.listeningPort;
				String xmlBody=null;
				if (!status.equals("closed") )                
					xmlBody=XMLpidfParser.createXMLBody(status,subStatus,subscriberName,
					contactAddress);
            
				Dialog dialog=subscriber.getDialog();
				if (dialog==null) {
					System.out.println("ERROR, sendNotifyToAllSubscribers(), Pb to "+
					"retrieve the dialog, NOTIFY not sent!");
				}
				else
					sendNotify(xmlBody,dialog);
			 }
		}
		catch (Exception ex) {
			ex.printStackTrace();
		} 
	}

	/**
	 * Send a notification of the presence status of the application to a 
	 * subscriber
	 * @param subscriber - the subscriber to notify
	 * @param status - the new presence status of the application
	 * @param subStatus - the new presence substatus of the application
	 */
	public void sendNotifyToSubscriber(Subscriber subscriber,String status,String subStatus){
		String subscriberName=subscriber.getAddress();
            
		String contactAddress= configuration.contactIPAddress+":"+
			configuration.listeningPort;
		String xmlBody=null;
		if (!status.equals("closed") )                
			xmlBody=XMLpidfParser.createXMLBody(status,subStatus,subscriberName,
			contactAddress);

		Dialog dialog=subscriber.getDialog();
		if (dialog==null) {
			System.out.println("ERROR, sendNotifyToAllSubscribers(), PB to "+
			"retrieve the dialog, NOTIFY not sent!");
		}
		else
			sendNotify(xmlBody,dialog);
	}

	/**
	 * Send a notify from a dialog
	 * @param body -  the body of the notify
	 * @param dialog - the dialog form which the notify will be created
	 */
	public void sendNotify(String body,Dialog dialog) {
		try{
			// We send the NOTIFY!!!
        
			// we create the Request-URI: the one of the proxy
			HeaderFactory headerFactory=MessageListener.headerFactory;
			AddressFactory addressFactory=MessageListener.addressFactory;
			MessageFactory messageFactory=MessageListener.messageFactory;
			//SipProvider sipProvider=imUA.getSipProvider();
        
			String transport=configuration.signalingTransport;
			String proxyAddress=configuration.outboundProxy;
			int proxyPort=configuration.proxyPort;
        
			SipURI requestURI=null;
			if (proxyAddress!=null) {
				 requestURI=addressFactory.createSipURI(null,proxyAddress);
				 requestURI.setPort(proxyPort);
				 requestURI.setTransportParam(transport);
			}
			else {
				System.out.println("DEBUG, IMNotifyProcessing, sendNotify(), request-uri is null");
				return;
			}
        
       
			Address localAddress=dialog.getLocalParty();
			Address remoteAddress=dialog.getRemoteParty();  
                  
			FromHeader fromHeader=headerFactory.createFromHeader(localAddress,dialog.getLocalTag());
			ToHeader toHeader=headerFactory.createToHeader(remoteAddress,dialog.getRemoteTag());
        
			int cseq=dialog.getLocalSequenceNumber();
			CSeqHeader cseqHeader=headerFactory.createCSeqHeader(cseq,"NOTIFY");
            
			CallIdHeader callIdHeader=dialog.getCallId();
			//Listening Point
			ListeningPoint listeningPoint = messageListener.sipProvider.getListeningPoint();    
			  
			//ViaHeader
			ArrayList viaHeaders = null;        
			viaHeaders = new ArrayList();
			try {
				ViaHeader viaHeader = MessageListener.headerFactory.createViaHeader(
					configuration.contactIPAddress,
					listeningPoint.getPort(),
					listeningPoint.getTransport(),
					null
					);
				viaHeaders.add(viaHeader);
			}
			catch (ParseException ex) {
				//Shouldn't happen
				ex.printStackTrace();
			}
			catch (InvalidArgumentException ex) {
				//Should never happen
				System.out.println("The application is corrupt");                
			}
        
			// MaxForwards header:
			MaxForwardsHeader maxForwardsHeader=headerFactory.createMaxForwardsHeader(70);
        
			Request request=null;
			ClientTransaction clientTransaction=null;
			if (body==null) {
            
				request=messageFactory.createRequest(requestURI,"NOTIFY",
				callIdHeader,cseqHeader,fromHeader,toHeader,viaHeaders,maxForwardsHeader);
           
				// We have to add an Expires-Header of 0!!!
				ExpiresHeader expiresHeader=headerFactory.createExpiresHeader(0);
				request.setHeader(expiresHeader);
            
			}
			else {
				body=body+"\r\n";
				// Content-Type:
				ContentTypeHeader contentTypeHeader=headerFactory.createContentTypeHeader(
				"application","xpidf+xml");
            
				request=messageFactory.createRequest(requestURI,"NOTIFY",
				callIdHeader,cseqHeader,fromHeader,toHeader,viaHeaders,maxForwardsHeader
				,contentTypeHeader,body);
               
			}         
			//Route Header
			SipURI routeURI=null;
			try{
				routeURI=MessageListener.addressFactory.createSipURI(
					  null,
					  configuration.outboundProxy);
			}
			catch(ParseException pe){
				pe.printStackTrace();
			}
			routeURI.setPort(configuration.proxyPort);
			try {
				routeURI.setTransportParam(configuration.signalingTransport);
			}
			catch(ParseException pe){
				pe.printStackTrace();
			}
			RouteHeader routeHeader = MessageListener.headerFactory.createRouteHeader(
				MessageListener.addressFactory.createAddress(routeURI));			           
			request.addHeader(routeHeader);
		
			// WE have to add a new Header: "Subscription-State"
			System.out.println("DEBUG, sendNotify(), We add the Subscription-State"+
			" header to the request");
			Header header=headerFactory.createHeader("Subscription-State","active");
			request.setHeader(header);
        
			// WE have to add a new Header: "Event"
			header=headerFactory.createHeader("Event","presence");
			request.setHeader(header);
        
			// ProxyAuthorization header if not null:
			//ProxyAuthorizationHeader proxyAuthHeader=imUA.getProxyAuthorizationHeader();
			//if (proxyAuthHeader!=null) 
				//request.setHeader(proxyAuthHeader);
        
			clientTransaction=messageListener.sipProvider.getNewClientTransaction(request);
			dialog.sendRequest(clientTransaction);
        
			System.out.println("DEBUG, sendNotify(),"+
			" NOTIFY sent:\n" );
			System.out.println(request.toString());
		}
		catch (Exception ex) {
			ex.printStackTrace();
		}
	}                	    
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美美女喷水视频| 日韩欧美区一区二| 久久99精品国产| 亚洲欧美偷拍三级| 欧美第一区第二区| 色一区在线观看| 国产精品一二二区| 首页综合国产亚洲丝袜| 久久精品人人做人人综合| 欧美三级日韩三级国产三级| 成人免费看黄yyy456| 蜜桃一区二区三区四区| 亚洲一级片在线观看| 国产精品卡一卡二| 久久综合久久99| 91精品国产91热久久久做人人| 不卡一卡二卡三乱码免费网站| 精品在线免费视频| 视频一区二区欧美| 亚洲精品亚洲人成人网在线播放| 久久久久久久精| 99re视频这里只有精品| 国产99久久久国产精品潘金网站| 欧美aa在线视频| 亚洲高清免费观看高清完整版在线观看| 国产精品天干天干在线综合| 精品福利av导航| 日韩欧美一区中文| 日韩一区二区三免费高清| 欧美日韩精品一区二区三区四区| 色综合久久综合网| 91视频在线看| 97se狠狠狠综合亚洲狠狠| 成人av电影在线网| 成人动漫一区二区在线| 成人av手机在线观看| www.亚洲色图.com| 99国产精品久| 欧洲激情一区二区| 欧美视频一区在线观看| 欧美图区在线视频| 欧美巨大另类极品videosbest | 亚洲国产精华液网站w| 久久伊99综合婷婷久久伊| 久久色视频免费观看| 久久青草国产手机看片福利盒子 | 欧美挠脚心视频网站| 欧美日韩aaaaaa| 欧美人伦禁忌dvd放荡欲情| 91精品综合久久久久久| 日韩无一区二区| 久久久夜色精品亚洲| 亚洲国产精品v| 亚洲综合区在线| 图片区小说区区亚洲影院| 麻豆专区一区二区三区四区五区| 国模套图日韩精品一区二区| 国产精品18久久久久久vr| av网站一区二区三区| 91极品美女在线| 日韩色在线观看| 中文字幕不卡在线| 一区二区三区精品| 亚洲电影在线播放| 九色综合狠狠综合久久| 粉嫩久久99精品久久久久久夜| 不卡大黄网站免费看| 欧美亚洲动漫精品| 精品日韩99亚洲| 成人欧美一区二区三区黑人麻豆 | 欧美综合一区二区三区| 91精品国产品国语在线不卡| 久久久精品国产免费观看同学| 1024国产精品| 日韩不卡手机在线v区| 国产丶欧美丶日本不卡视频| 一道本成人在线| 日韩精品一区国产麻豆| 国产精品久久久久久久第一福利| 亚洲电影第三页| 欧美日韩一区中文字幕| 精品福利视频一区二区三区| 亚洲精选视频免费看| 日韩精品福利网| www..com久久爱| 日韩欧美一级片| 自拍视频在线观看一区二区| 日本中文一区二区三区| 99re在线精品| 久久色视频免费观看| 午夜精品福利一区二区三区av| 国产一区二三区| 欧美日韩免费观看一区三区| 国产日本亚洲高清| 日韩精品亚洲专区| 99国产精品国产精品毛片| 日韩三级中文字幕| 亚洲一二三区不卡| 成人黄色777网| 精品国产乱码久久久久久影片| 一区二区三区四区在线| 国产电影一区在线| 日韩欧美一级特黄在线播放| 亚洲成人av福利| 91视频91自| 日本一区二区免费在线观看视频 | 亚洲午夜激情网页| 国产激情视频一区二区在线观看 | 91丨porny丨在线| 国产人久久人人人人爽| 蜜桃av一区二区| 欧美日韩一区二区在线观看视频| 国产精品美日韩| 国产激情一区二区三区四区| 欧美不卡123| 视频精品一区二区| 欧美午夜一区二区三区免费大片| 亚洲欧洲精品一区二区三区| 国产乱码精品一区二区三| 精品欧美一区二区久久 | 精一区二区三区| 日韩三级.com| 美美哒免费高清在线观看视频一区二区 | 成人综合婷婷国产精品久久免费| 欧美成人官网二区| 日本大胆欧美人术艺术动态| 欧美日韩不卡在线| 亚洲第一电影网| 色噜噜偷拍精品综合在线| 国产精品国产成人国产三级| 国产成人精品免费一区二区| 久久这里只有精品6| 国产另类ts人妖一区二区| 欧美成人a视频| 狠狠色丁香久久婷婷综合_中 | www成人在线观看| 美日韩一区二区三区| 精品乱码亚洲一区二区不卡| 精品无人区卡一卡二卡三乱码免费卡| 4438亚洲最大| 久久精品久久久精品美女| 欧美成人女星排名| 国产在线精品一区二区夜色| 精品999在线播放| 国产在线视频精品一区| 国产欧美精品日韩区二区麻豆天美| 国产一区日韩二区欧美三区| 国产日韩av一区二区| 成人污视频在线观看| 国产精品国产三级国产普通话99 | 欧美在线观看视频在线| 亚洲国产一区二区三区| 欧美日韩午夜精品| 人妖欧美一区二区| 精品免费国产一区二区三区四区| 国产一区激情在线| 中文字幕一区二区三区不卡 | 91精品国产91久久久久久一区二区 | 欧美日韩第一区日日骚| 久久精品国产免费看久久精品| 精品欧美黑人一区二区三区| 成人福利视频网站| 亚洲九九爱视频| 欧美一级一区二区| 国产91露脸合集magnet | 国产麻豆午夜三级精品| 国产精品美女视频| 欧美性大战久久久| 久久精工是国产品牌吗| 中国色在线观看另类| 欧美性受xxxx| 精品一区二区三区在线视频| 国产精品伦一区二区三级视频| 欧洲在线/亚洲| 激情五月婷婷综合| 一区二区三区在线视频免费观看| 欧美大白屁股肥臀xxxxxx| 成人精品小蝌蚪| 肉肉av福利一精品导航| 国产欧美精品一区aⅴ影院| 精品视频在线视频| 国产精品一二三| 五月婷婷另类国产| 中文字幕精品一区二区三区精品| 欧美日韩亚洲高清一区二区| 国产麻豆精品久久一二三| 亚洲成人黄色小说| 国产精品全国免费观看高清 | 国产日韩av一区| 欧美精品精品一区| 成人av电影在线观看| 奇米在线7777在线精品| 中文字幕综合网| 久久这里都是精品| 91麻豆精品国产91久久久久久久久| 成人黄色软件下载| 精品一区二区三区蜜桃| 亚洲福利视频一区二区| 欧美激情中文不卡| 日韩午夜在线影院|