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

📄 vijxtacallcontrol.java

📁 用jxse开发的一个p2p通讯软件 有聊天 文件共享 视频3大功能
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                LOG.info("callControl : " +                        COMMAND_VIJXTA_DISCONNECT_ACCEPT + " received");            }            if (getProtocolState() == SESSION_VIJXTA_ENDED) {                updateAckThread(command);                setProtocolState(SESSION_VIJXTA_DISCONNECT_ACCEPT_RECEIVED);                //disconnect from host - close window no more calls from this tab                localActionEndSession();                setProtocolState(SESSION_VIJXTA_DISCONNECTED);            } else {                // the other side is going down... kill session                // TODO:                postProtocolStateException(SESSION_VIJXTA_ENDED);            }        } else if (COMMAND_VIJXTA_ROUND_TRIP_REQUEST.equals(command)) {            if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                LOG.info("callControl : " +                        COMMAND_VIJXTA_ROUND_TRIP_REQUEST + " received");            }            localActionRoundTripRequestReceived(msg);        } else if (COMMAND_VIJXTA_ROUND_TRIP_ACCEPT.equals(command)) {            if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                LOG.info("callControl : " +                        COMMAND_VIJXTA_ROUND_TRIP_ACCEPT + " received");            }            localActionRoundTripAcceptReceived(msg);        }    }//call control    private void localActionRoundTripRequestReceived(DialogMessage msg) {        HashMap<String, MessageElement> map = new HashMap<String, MessageElement>();        map.put(TAG_ROUND_TRIP_REQUEST_TIME, msg.getMessageElement(TAG_ROUND_TRIP_REQUEST_TIME));        this.sendCommand(COMMAND_VIJXTA_ROUND_TRIP_ACCEPT, null, map);    }    private void localActionRoundTripAcceptReceived(DialogMessage msg) {        MessageElement me = msg.getMessageElement(TAG_ROUND_TRIP_REQUEST_TIME);        if (me != null) {            String roundTripString = me.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<String, MessageElement> elementMap = new HashMap<String, MessageElement>();        String originTimeString = String.valueOf(System.currentTimeMillis());        StringMessageElement originTimeElement = new StringMessageElement(                TAG_ROUND_TRIP_REQUEST_TIME, originTimeString, null);        elementMap.put(TAG_ROUND_TRIP_REQUEST_TIME, originTimeElement);        this.sendCommand(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 (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("expected " +                    this.getProtocolStateString(expectedProtocolState) +                    " - got " +                    this.getProtocolStateString(this.getProtocolState()));        }    }    /**     * Called on session end.     */    public void destroy() {        if (this.getProtocolState() != 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 sessionStateTable.get(new Integer(sessionState));    }    /**     * message has been received... determine if its the correct response     */    protected void updateAckThread(String command) {        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("Checking AckThread");        }        if (messageAckThread != null) {            messageAckThread.setMessageAcknowledged(command);            if (messageAckThread.isThreadEnded()) {                messageAckThread = null;            }        } else {            if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                LOG.info("MessageAckThread is null!!");            }        }    }    protected void localActionConfigRequestReceived(DialogMessage msg) {        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("localActionConfigRequestReceived");        }        if (configWaitTimerTask != null) {            if (Logging.SHOW_INFO && LOG.isLoggable(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 (Logging.SHOW_INFO && LOG.isLoggable(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 (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("ConfigMessage Received: \n" + msg.toString());        }        MessageElement me;        me = msg.getMessageElement(TAG_IMAGE_FORMAT_SIZE_ELEMENT);        if (me != null) {            String remoteFormatSizeString = me.toString();            if (remoteFormatSizeString != null) {                getRemoteMonitorControl().setFormatSize(ViJxtaUtil.stringToDimension(remoteFormatSizeString));                if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                    LOG.info("Remote Format Size Received: " +                            remoteFormatSizeString);                }            }        }        me = msg.getMessageElement(TAG_IMAGE_QUALITY_ELEMENT);        if (me != null) {            String remoteImageQualityString = me.toString();            if (remoteImageQualityString != null) {                getRemoteMonitorControl().setImageCompression(Integer.valueOf(remoteImageQualityString).intValue());                if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                    LOG.info("Remote Image Quality Received: " +                            remoteImageQualityString);                }            }        }        me = msg.getMessageElement(TAG_IMAGE_FORMAT_TYPE_ELEMENT);        if (me != null) {            String remoteFormatTypeString = me.toString();            if (remoteFormatTypeString != null) {                getRemoteMonitorControl().setFormatType(remoteFormatTypeString);                if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                    LOG.info("Remote Format Type Received: " +                            remoteFormatTypeString);                }            }        }        me = msg.getMessageElement(TAG_IMAGE_TRANSMIT_ELEMENT);        if (me != null) {            String remoteImageTransmitString = me.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 (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                    LOG.info("Remote Image Transmit Received: " +                            remoteImageTransmitString);                }            }        }        me = msg.getMessageElement(TAG_IMAGE_RECEIVE_ELEMENT);        if (me != null) {            MessageElement remoteImageReceiveElement;            remoteImageReceiveElement = me;            String remoteImageReceiveString = remoteImageReceiveElement.toString();            if (remoteImageReceiveString != null) {                this.setRemotePeerReceive(Boolean.valueOf(remoteImageReceiveString).booleanValue());                if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                    LOG.info("Remote Image Receive Received: " +                            remoteImageReceiveString);                }            }        }    }    public void setRemotePeerTransmit(boolean remotePeerTransmit) {        this.remotePeerTransmit = remotePeerTransmit;    }    public void setRemotePeerReceive(boolean remotePeerReceive) {        this.remotePeerReceive = remotePeerReceive;    }    public boolean isRemotePeerTransmit() {        return this.remotePeerTransmit;    }    public boolean isRemotePeerReceive() {        return this.remotePeerReceive;    }    protected HashMap<String, MessageElement> getConfigElements() {        HashMap<String, MessageElement> elementMap = new HashMap<String, MessageElement>();        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("LocalPeer Transmit ? " +                    this.getLocalMonitorControl().isTransmit());        }        if (this.getLocalMonitorControl().isTransmit()) {            String imageQualityString = String.valueOf(getLocalMonitorControl().getImageCompression());            StringMessageElement imageQualityElement = new StringMessageElement(                    TAG_IMAGE_QUALITY_ELEMENT, imageQualityString, null);            elementMap.put(TAG_IMAGE_QUALITY_ELEMENT, imageQualityElement);            String imageFormatSizeString = String.valueOf(ViJxtaUtil.                    dimensionToString(getLocalMonitorControl().getFormatSize()));            StringMessageElement imageFormatSizeElement = new StringMessageElement(                    TAG_IMAGE_FORMAT_SIZE_ELEMENT, imageFormatSizeString, null);            elementMap.put(TAG_IMAGE_FORMAT_SIZE_ELEMENT, imageFormatSizeElement);            String imageFormatTypeString = String.valueOf(getLocalMonitorControl().getMimeType());            StringMessageElement imageFormatTypeElement = new StringMessageElement(                    TAG_IMAGE_FORMAT_TYPE_ELEMENT, imageFormatTypeString, null);            elementMap.put(TAG_IMAGE_FORMAT_TYPE_ELEMENT, imageFormatTypeElement);        } else {            LOG.info("AddElement NOT TRANSMITTING");        }        String imageReceiveString = String.valueOf(getRemoteMonitorControl().isReceive());        StringMessageElement imageReceiveElement = new StringMessageElement(                TAG_IMAGE_RECEIVE_ELEMENT, imageReceiveString, null);        elementMap.put(TAG_IMAGE_RECEIVE_ELEMENT, imageReceiveElement);        boolean transmit = false;        /** fix for issue#236, check for JMF only necessary when local device         * is in use. for internet cams a JMF check can be skipped.         */        if (this.localVideoSourceType == LOCAL_DEVICE) {            transmit = (this.isJMFPresent && getLocalMonitorControl().isTransmit());        } else if (this.localVideoSourceType == NETWORKED_DEVICE) {            transmit = true; //xxx there should be checking here for errors        } else if (this.localVideoSourceType == NO_DEVICE) {            transmit = false;        }        String imageTransmitString = String.valueOf(transmit);        StringMessageElement imageTransmitElement = new StringMessageElement(                TAG_IMAGE_TRANSMIT_ELEMENT, imageTransmitString, null);        elementMap.put(TAG_IMAGE_TRANSMIT_ELEMENT, imageTransmitElement);        return elementMap;    }    /**     * Command SendStartRquest to remote.     * XML elements attached:     * -compression(image quality) level that remote peer is sending.     * -format size (ie: 360x240)     * -image format type (ie: jpeg, png, bmp)     */    protected void localActionSendConfigRequest() {        HashMap<String, MessageElement> configMap = getConfigElements();        sendCommand(COMMAND_VIJXTA_CONFIG_REQUEST,

⌨️ 快捷键说明

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