📄 vijxtacallcontrol.java
字号:
}else if(COMMAND_VIJXTA_HANGUP_ACCEPT.equals (command)) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("callControl : "+this.COMMAND_VIJXTA_HANGUP_ACCEPT+" received"); } if(getProtocolState () == this.SESSION_VIJXTA_HANGUP_REQUEST_SENT) { updateAckThread (command); setProtocolState (this.SESSION_VIJXTA_HANGUP_ACCEPT_RECEIVED); //hang up call localActionEndCall (); sendCommand (this.COMMAND_VIJXTA_DISCONNECT_REQUEST,this.COMMAND_VIJXTA_DISCONNECT_ACCEPT); setProtocolState (this.SESSION_VIJXTA_DISCONNECT_REQUEST_SENT); }else{ postProtocolStateException (this.SESSION_VIJXTA_HANGUP_REQUEST_SENT); } }else if(COMMAND_VIJXTA_DISCONNECT_REQUEST.equals (command)) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("callControl : "+this.COMMAND_VIJXTA_DISCONNECT_REQUEST+" received"); } if(getProtocolState () == this.SESSION_VIJXTA_ENDED) { setProtocolState (this.SESSION_VIJXTA_DISCONNECT_REQUEST_RECEIVED); sendCommand (this.COMMAND_VIJXTA_DISCONNECT_ACCEPT,null); setProtocolState (this.SESSION_VIJXTA_DISCONNECT_ACCEPT_SENT); //disconnect from host - close window no more calls from this tab if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("Disconnecting"); } localActionEndSession (); setProtocolState (this.SESSION_VIJXTA_DISCONNECTED); }else{ // the other side is going down... kill session // this is the non graceful shutdown withthe protocol being in any state setProtocolState (this.SESSION_VIJXTA_DISCONNECT_REQUEST_RECEIVED); sendCommand (this.COMMAND_VIJXTA_DISCONNECT_ACCEPT,null); setProtocolState (this.SESSION_VIJXTA_DISCONNECT_ACCEPT_SENT); //disconnect from host - close window no more calls from this tab localActionEndSession (); setProtocolState (this.SESSION_VIJXTA_DISCONNECTED); postProtocolStateException (this.SESSION_VIJXTA_ENDED); if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("Ungraceful disconnect received...Going Down"); } } }else if(COMMAND_VIJXTA_DISCONNECT_ACCEPT.equals (command)) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("callControl : "+this.COMMAND_VIJXTA_DISCONNECT_ACCEPT+" received"); } if(getProtocolState () == this.SESSION_VIJXTA_ENDED) { updateAckThread (command); setProtocolState (this.SESSION_VIJXTA_DISCONNECT_ACCEPT_RECEIVED); //disconnect from host - close window no more calls from this tab localActionEndSession (); setProtocolState (this.SESSION_VIJXTA_DISCONNECTED); }else{ // the other side is going down... kill session // TODO: postProtocolStateException (this.SESSION_VIJXTA_ENDED); } }else if(COMMAND_VIJXTA_ROUND_TRIP_REQUEST.equals (command)) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("callControl : "+this.COMMAND_VIJXTA_ROUND_TRIP_REQUEST+" received"); } localActionRoundTripRequestReceived (msg); }else if(COMMAND_VIJXTA_ROUND_TRIP_ACCEPT.equals (command)) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("callControl : "+this.COMMAND_VIJXTA_ROUND_TRIP_ACCEPT+" received"); } localActionRoundTripAcceptReceived (msg); } }//call control private void localActionRoundTripRequestReceived (DialogMessage msg) { HashMap map = new HashMap (); map.put (this.TAG_ROUND_TRIP_REQUEST_TIME, msg.getMessageElement (this.TAG_ROUND_TRIP_REQUEST_TIME)); this.sendCommand (this.COMMAND_VIJXTA_ROUND_TRIP_ACCEPT, null, map); } private void localActionRoundTripAcceptReceived (DialogMessage msg) { MessageElement me = msg.getMessageElement (this.TAG_ROUND_TRIP_REQUEST_TIME); if(me != null) { ByteArrayMessageElement roundTripElement = (ByteArrayMessageElement) me; String roundTripString = roundTripElement.toString (); if( roundTripString != null) { try { long originTime = Long.valueOf (roundTripString).longValue (); long destinationTime = System.currentTimeMillis (); this.setRoundTripTime ( destinationTime - originTime);; }catch(NumberFormatException nfx) { nfx.printStackTrace (); } } } } private void localActionSendRoundTripRequest () { HashMap elementMap = new HashMap (); String originTimeString = String.valueOf (System.currentTimeMillis ()); StringMessageElement originTimeElement = new StringMessageElement ( this.TAG_ROUND_TRIP_REQUEST_TIME, originTimeString, null); elementMap.put (this.TAG_ROUND_TRIP_REQUEST_TIME,originTimeElement); this.sendCommand (this.COMMAND_VIJXTA_ROUND_TRIP_REQUEST, null, elementMap); } private void setRoundTripTime (long roundTrip) { this.roundTrip = roundTrip; } public long getRoundTripTime () { return this.roundTrip; } private void postProtocolStateException (int expectedProtocolState) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("expected "+ this.getProtocolStateString (expectedProtocolState) + " - got "+this.getProtocolStateString (this.getProtocolState ())); } } /** * Called on session end. */ public void destroy () { if(this.getProtocolState () != this.SESSION_VIJXTA_DISCONNECTED) { this.localActionMessageGoneUnAcknowledged (); } if(receiveTimeoutThread != null) { receiveTimeoutThread.stopThread (); receiveTimeoutThread = null; } this.stopTransmitReceive (); this.stopMonitors (); if(roundTripTimerTask != null) { roundTripTimerTask.cancel (); } if(generalTimer != null ) { generalTimer.cancel (); } } private String getProtocolStateString (int sessionState) { return (String) sessionStateTable.get (new Integer (sessionState)); } /** * message has been received... determine if its the correct response */ protected void updateAckThread (String command) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("Checking AckThread"); } if(messageAckThread != null) { messageAckThread.setMessageAcknowledged (command); if(messageAckThread.isThreadEnded ()) { messageAckThread = null; } }else{ if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("MessageAckThread is null!!"); } } } protected void localActionConfigRequestReceived (DialogMessage msg) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("localActionConfigRequestReceived"); } if(configWaitTimerTask != null) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("localActionConfigRequestReceived: cancel configWaitTimerTask"); } configWaitTimerTask.cancel (); } if( this.isConfigured()) { localActionSendConfigAccept (); }else{ //we wait for user to configure } } protected void localActionConfigAcceptReceived (DialogMessage msg) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("localActionConfigRequestReceived"); } } /* * XML elements attached: * -compression(quality) level that remote peer is sending. * -format size (ie: 360x240) * -image format type (ie: jpeg, png, bmp) */ protected void parseConfigMessage (DialogMessage msg) { if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("ConfigMessage Received: \n"+ msg.toString()); } MessageElement me = null; me = msg.getMessageElement (this.TAG_IMAGE_FORMAT_SIZE_ELEMENT); if(me != null) { ByteArrayMessageElement remoteFormatSizeElement = (ByteArrayMessageElement) me; String remoteFormatSizeString = remoteFormatSizeElement.toString (); if( remoteFormatSizeString != null) { getRemoteMonitorControl ().setFormatSize (ViJxtaUtil.stringToDimension (remoteFormatSizeString)); if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("Remote Format Size Received: "+ remoteFormatSizeString); } } } me = msg.getMessageElement (this.TAG_IMAGE_QUALITY_ELEMENT); if(me != null) { ByteArrayMessageElement remoteImageQualityElement = (ByteArrayMessageElement) me; String remoteImageQualityString = remoteImageQualityElement.toString (); if( remoteImageQualityString != null) { getRemoteMonitorControl ().setImageCompression (Integer.valueOf (remoteImageQualityString).intValue ()); if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("Remote Image Quality Received: " + remoteImageQualityString); } } } me = msg.getMessageElement (this.TAG_IMAGE_FORMAT_TYPE_ELEMENT); if(me != null) { ByteArrayMessageElement remoteFormatTypeElement = (ByteArrayMessageElement) me; String remoteFormatTypeString = remoteFormatTypeElement.toString (); if( remoteFormatTypeString != null) { getRemoteMonitorControl ().setFormatType (remoteFormatTypeString); if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("Remote Format Type Received: " + remoteFormatTypeString); } } } me = msg.getMessageElement (this.TAG_IMAGE_TRANSMIT_ELEMENT); if(me != null) { ByteArrayMessageElement remoteImageTransmitElement = (ByteArrayMessageElement) me; String remoteImageTransmitString = remoteImageTransmitElement.toString (); if( remoteImageTransmitString != null) { this.setRemotePeerTransmit (Boolean.valueOf (remoteImageTransmitString).booleanValue ()); // weather we receive is not determined by their choice to //transmit, but instead by our choice to receive their // transmition; hence this is determined by the local user //this.getRemoteMonitorControl ().setReceive (Boolean.valueOf (remoteImageTransmitString).booleanValue ()); if (LOG.isEnabledFor (Level.INFO)) { LOG.info ("Remote Image Transmit Received: " + remoteImageTransmitString); } } } me = msg.getMessageElement (this.TAG_IMAGE_RECEIVE_ELEMENT);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -