⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 .#messageprocessor.java.1.20

📁 It is Java for SIP phone
💻 20
📖 第 1 页 / 共 3 页
字号:
				messageListener.sipMeetingManager.setRegisterStatus(					RegisterStatus.NOT_REGISTERED);		} else {			messageListener.sipMeetingManager.setRegisterStatus(				RegisterStatus.REGISTERED);		}	}	/**	 * Process the OK received response for a BYE	 * @param clientTransaction - the client transaction associated with the response	 * @param byeOK - the OK received response for a BYE	 */	public void processByeOK(		ClientTransaction clientTransaction,		Response byeOK) {		CallManager callManager =			messageListener.sipMeetingManager.getCallManager();		//Find the Audio call		Call call =			callManager.findCall(clientTransaction.getDialog().getDialogId());		if (call instanceof AudioCall) {			AudioCall audioCall = (AudioCall) call;			audioCall.setStatus(AudioCall.NOT_IN_A_CALL);			messageListener.sipMeetingManager.notifyObserversNewCallStatus(				audioCall);			/*if(audioCall.getVoiceMessaging()){				stopVoiceMessagingSchedule();					}								else{				audioCall.getMediaManager().stopMediaSession();			}*/			System.out.println(				"Audio Call removed : " + call.getDialog().getDialogId());			//Remove the call			callManager.removeAudioCall(audioCall);		} else {			IMCall imCall = (IMCall) call;			//Remove the call			System.out.println(				"IM Call removed : " + call.getDialog().getDialogId());			callManager.removeIMCall(imCall);		}	}	/**	 * Process the OK received response for a CANCEL	 * @param clientTransaction - the client transaction associated with the response	 * @param cancelOK - the OK received response for a CANCEL	 */	public void processCancelOK(		ClientTransaction clientTransaction,		Response cancelOK) {		CallManager callManager =			messageListener.sipMeetingManager.getCallManager();		//Strip out the callee		SipURI calleeURI =			(SipURI) ((ToHeader) cancelOK.getHeader(ToHeader.NAME))				.getAddress()				.getURI();		String callee =			"sip:"				+ calleeURI.getUser()				+ "@"				+ calleeURI.getHost().trim().toLowerCase();		//Find the Audio call		AudioCall call = callManager.findAudioCall(callee);		call.setStatus(AudioCall.NOT_IN_A_CALL);		messageListener.sipMeetingManager.notifyObserversNewCallStatus(call);		callManager.removeAudioCall(call);	}	/**	 * Process the OK received response for a MESSAGE	 * @param clientTransaction - the client transaction associated with the response	 * @param cancelOK - the OK received response for a MESSAGE	 */	public void processMessageOK(		ClientTransaction clientTransaction,		Response messageOK) {	}	/**	 * Process the OK received response for a SUBSCRIBE	 * @param clientTransaction - the client transaction associated with the response	 * @param cancelOK - the OK received response for a MESSAGE	 */	public void processSubscribeOK(		ClientTransaction clientTransaction,		Response subscribeOK) {		messageListener.sipMeetingManager.presenceAllowed = true;		Address address =			((FromHeader) subscribeOK.getHeader(FromHeader.NAME)).getAddress();		String sender = null;		if (address.getURI().isSipURI()) {			SipURI sipURI = ((SipURI) address.getURI());			String host = sipURI.getHost();			String user = sipURI.getUser();			sender = user + "@" + host;		}		/*Subscriber subscriber = new Subscriber(sender);		subscriber.setDialog(clientTransaction.getDialog());		messageListener.sipMeetingManager.getPresentityManager().			sendNotifyToSubscriber(									subscriber,									"open",									"online");*/	}	/**	 * Process the OK received response for a SUBSCRIBE	 * @param clientTransaction - the client transaction associated with the response	 * @param cancelOK - the OK received response for a MESSAGE	 */	public void processSubscribeAccepted(		ClientTransaction clientTransaction,		Response subscribeAccepted) {		messageListener.sipMeetingManager.presenceAllowed = true;		/*Address address=((FromHeader)subscribeOK.getHeader(FromHeader.NAME)).getAddress();		String sender=null;		if(address.getURI().isSipURI()){			SipURI sipURI=((SipURI)address.getURI());			String host=sipURI.getHost();			String user=sipURI.getUser();			sender=user+"@"+host;		}*/		/*Subscriber subscriber = new Subscriber(sender);		subscriber.setDialog(clientTransaction.getDialog());		messageListener.sipMeetingManager.getPresentityManager().			sendNotifyToSubscriber(									subscriber,									"open",									"online");*/	}	/**	 * Process the OK received response for a INVITE	 * @param clientTransaction - the client transaction associated with the response	 * @param inviteOK - the OK received response for a INVITE	 */	public void processInviteOK(		ClientTransaction clientTransaction,		Response inviteOK) {		CallManager callManager =			messageListener.sipMeetingManager.getCallManager();		//Strip out the callee		SipURI calleeURI =			(SipURI) ((ToHeader) inviteOK.getHeader(ToHeader.NAME))				.getAddress()				.getURI();		String callee =			"sip:" + calleeURI.getUser() + "@" + calleeURI.getHost();		//Find the Audio call		AudioCall call = callManager.findAudioCall(callee);		//Send ACK		try {			Request ack =				(Request) clientTransaction.getDialog().createRequest(					Request.ACK);			ack.setRequestURI(calleeURI);			System.out.println("Sending ACK : \n" + ack.toString());			try {				clientTransaction.getDialog().sendAck(ack);			} catch (SipException ex) {				System.out.println("Could not send out the ACK request! ");				ex.printStackTrace();			}			//messageListener.sipProvider.sendRequest(ack);                        		} catch (SipException ex) {			ex.printStackTrace();		}		ContentTypeHeader contentTypeHeader =			(ContentTypeHeader) inviteOK.getHeader(ContentTypeHeader.NAME);		// no content type header means other end does not support sdp.		if (contentTypeHeader != null) {			String type = contentTypeHeader.getContentType();			String subType = contentTypeHeader.getContentSubType();			//System.out.println("the other end answer us with "+subType);				        				messageListener.sipMeetingManager.notifyObserversNewCallStatus(				call);			if (type.equals("application") && subType.equals("sdp")) {				//Start the media session				MediaManager mediaManager = call.getMediaManager();				call.setVoiceMesaging(false);				mediaManager.prepareMediaSession(					new String(inviteOK.getRawContent()));				mediaManager.startMediaSession(true);			}		} else {			// else start the media messaging session.			ListIterator it = inviteOK.getHeaders(AcceptHeader.NAME);			while (it.hasNext()) {				AcceptHeader next = (AcceptHeader) it.next();				if (next.getContentType().equals("audio")					&& (next.getContentSubType().equals("gsm")						|| next.getContentSubType().equals("x-gsm"))) {					call.setVoiceMesaging(true);					//schedule to send the voice messages every 2 sec.					startVoiceMessagingSchedule(callee);				} else if (					next.getContentType().equals("text")						&& next.getContentSubType().equals("plain")) {					// TODO -- textMessaging.setTextMessaging(true);				}			}		}		call.setStatus(AudioCall.IN_A_CALL);		messageListener.sipMeetingManager.notifyObserversNewCallStatus(call);	}	/**	 * Process the Busy here response	 * @param clientTransaction - the client transaction associated with the response	 * @param busyhere - the Busy here response	 */	public void processBusyHere(		ClientTransaction clientTransaction,		Response busyHere) {		CallManager callManager =			messageListener.sipMeetingManager.getCallManager();		//Strip out the callee		SipURI calleeURI =			(SipURI) ((ToHeader) busyHere.getHeader(ToHeader.NAME))				.getAddress()				.getURI();		String callee =			"sip:" + calleeURI.getUser() + "@" + calleeURI.getHost();				Call call =			callManager.findCall(clientTransaction.getDialog().getDialogId());		if (call instanceof AudioCall) {			//Strip out the Call info Header			CallInfoHeader callInfoHeader=(CallInfoHeader)busyHere.getHeader(CallInfoHeader.NAME);			URI uri=callInfoHeader.getInfo();			((AudioCall)call).setURL(uri);			call.setStatus(AudioCall.BUSY);						messageListener.sipMeetingManager.notifyObserversNewCallStatus(				call);			System.out.println(				"Audio Call removed : " + call.getDialog().getDialogId());			callManager.removeAudioCall((AudioCall) call);		}	}	/**	 * Process the temporary Unavailable response	 * @param clientTransaction - the client transaction associated with the response	 * @param temporaryUnavailable - the temporary Unavailable response	 */	public void processTemporaryUnavailable(		ClientTransaction clientTransaction,		Response temporaryUnavailable) {		CallManager callManager =			messageListener.sipMeetingManager.getCallManager();		//Find the call				Call call =			callManager.findCall(clientTransaction.getDialog().getDialogId());		if (call instanceof AudioCall) {			AudioCall audioCall = (AudioCall) call;			audioCall.setStatus(Call.TEMPORARY_UNAVAILABLE);			messageListener.sipMeetingManager.notifyObserversNewCallStatus(				audioCall);			System.out.println(				"Audio Call removed : " + call.getDialog().getDialogId());			callManager.removeAudioCall(audioCall);		} else if (call instanceof IMCall) {			IMCall imCall = (IMCall) call;			imCall.setStatus(Call.TEMPORARY_UNAVAILABLE);			messageListener.sipMeetingManager.notifyObserversNewCallStatus(				imCall);			System.out.println(				"IM Call removed : " + call.getDialog().getDialogId());			callManager.removeIMCall(imCall);		}	}	/**	 * Process the 407 - Proxy Authentication Required	 * @param clientTransaction - the client transaction associated with the response	 * @param proxyAuthenticationRequired - the temporary Unavailable response	 */	public void processProxyAuthenticationRequired(		ClientTransaction clientTransaction,		Response proxyAuthenticationRequired) {		messageListener.sipMeetingManager.setRegisterStatus(			RegisterStatus.PROXY_AUTHENTICATION_REQUIRED);	}	/**	 * Process the 405 - Method Not Allowed	 * @param clientTransaction - the client transaction associated with the response	 * @param proxyAuthenticationRequired - the temporary Unavailable response	 */	public void processMethodNotAllowed(		ClientTransaction clientTransaction,		Response methodNotAllowed) {		messageListener.sipMeetingManager.presenceAllowed = false;	}	/**********************************************************************/	/*                                                                    */	/*                    Handling timeout messages                       */	/*                                                                    */	/**********************************************************************/	/**	 * Process the timed out MESSAGE	 * @param message - the timedout request 	 */	public void processTimedOutMessage(Request message) {		ToHeader toHeader = (ToHeader) (message.getHeader(ToHeader.NAME));		Address address = toHeader.getAddress();		if (address.getURI().isSipURI()) {			SipURI toURI = (SipURI) address.getURI();			messageListener.sipMeetingManager.notifyObserversIMReceived(				new String(message.getRawContent())					+ " has not been delivered successfully",				toURI.getUser() + "@" + toURI.getHost());		}	}	/**	 * Process the timed out REGISTER	 * @param message - the timedout request 	 */	public void processTimedOutRegister(Request register) {		messageListener.sipMeetingManager.setRegisterStatus(			RegisterStatus.NOT_REGISTERED);	}	/**	 * Process the timed out REGISTER	 * @param message - the timedout request 	 */	public void processTimedOutInvite(Request invite) {		messageListener.sipMeetingManager.setRegisterStatus(			AudioCall.NOT_IN_A_CALL);	}	/**	 * Process the Timeout received request	 * @param transaction - the transaction associated with the request	 * @param timeout - the timeout request	 */	public void processTimeout(Transaction transaction, Request timeout) {	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -