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

📄 vijxtacallcontrol.java

📁 用jxse开发的一个p2p通讯软件 有聊天 文件共享 视频3大功能
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                COMMAND_VIJXTA_CONFIG_ACCEPT,                configMap);        setProtocolState(SESSION_VIJXTA_CONFIG_REQUEST_SENT);    }    protected void localActionSendConfigAccept() {        HashMap<String, MessageElement> configMap = getConfigElements();        sendCommand(COMMAND_VIJXTA_CONFIG_ACCEPT,                null,                configMap);        setProtocolState(SESSION_VIJXTA_CONFIG_ACCEPT_SENT);    }    /**     * Command StartRquest received from remote     * XML elements attached:     * -compression(image quality) level that remote peer is sending.     * -format size (ie: 360x240)     * -image format type (ie: jpeg, png, bmp)     * SendAccept back to remote peer with attached elements     */    protected void localActionStartRequestReceived(DialogMessage msg) {    }    /**     * Sets if this sesseion is to be persisted     * TODO     */    public void setPersistSession(boolean persist, String fileName) {        this.sessionPersisted = persist;        this.sessionFileName = fileName;    }    /**     *     */    public boolean isSessionPersisted() {        return this.sessionPersisted;    }    /**     *     */    public String getSessionPersistFileName() {        return this.sessionFileName;    }    /**     *     */    public void viewActionPlaceCall() {        sendCommand(COMMAND_VIJXTA_START_REQUEST, COMMAND_VIJXTA_START_ACCEPT);        setProtocolState(SESSION_VIJXTA_START_REQUEST_SENT);        this.setCallStartTime();    }    public void viewActionEndCall() {        if (roundTripTimerTask != null) {            roundTripTimerTask.cancel();        }        sendCommand(COMMAND_VIJXTA_HANGUP_REQUEST, COMMAND_VIJXTA_HANGUP_ACCEPT);        setProtocolState(SESSION_VIJXTA_HANGUP_REQUEST_SENT);        this.localActionEndCall();    }    public boolean isLocallyInitiated() {        return this.locallyInitiated;    }    private void setConfigured(boolean configured) {        this.configured = configured;    }    private boolean isConfigured() {        return this.configured;    }    public void viewActionConfigured() {        this.setConfigured(true);        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("viewActionConfigured");        }        if (this.isLocallyInitiated()) {            this.localActionSendConfigRequest();            if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                LOG.info("viewActionConfigured: Locally initited");            }        } else {            if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                LOG.info("viewActionConfigured: NOT Locally initited");            }            if (this.getProtocolState() == ViJxtaCallControl.SESSION_VIJXTA_CONFIG_REQUEST_RECEIVED) {                if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                    LOG.info("viewActionConfigured: config request has been received");                }                localActionSendConfigAccept();            } else {                if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                    LOG.info("viewActionConfigured: config request has NOT been received. starting timer");                }                /** we'll wait 40 second for a config to come from the controlling                 *  peer. if none arrives then we go down. */                configWaitTimerTask = new TimerTask() {                    public void run() {                        if (getProtocolState() ==                                ViJxtaCallControl.SESSION_VIJXTA_CONFIG_REQUEST_RECEIVED) {                            if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                                LOG.info("configWaitTimerTask: CONFIG REQUEST Received");                            }                            localActionSendConfigAccept();                        } else {                            if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {                                LOG.info("configWaitTimerTask: Timeout wating for remote config");                            }                            destroy();                        }                    }                };                generalTimer.schedule(configWaitTimerTask, CONFIG_WAIT_TIMOUT);            }        }    }    /**     * Command EndCall reveived from remote peer     */    private void localActionEndCall() {        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("localActionEndCall");        }        setCallEndTime();        if (receiveTimeoutThread != null) {            receiveTimeoutThread.stopThread();            receiveTimeoutThread = null;        }        this.stopTransmitReceive();        this.stopMonitors();    }    private void stopMonitors() {        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("stopMonitors");        }        if (localMonitorControl != null) {            getLocalMonitorControl().stopMonitor();            getLocalMonitorControl().releaseHardware();        }        if (remoteMonitorControl != null) {            getRemoteMonitorControl().stopMonitor();            getRemoteMonitorControl().releaseHardware();        }    }    private void stopTransmitReceive() {        if (this.getLocalMonitorControl() != null) {            getLocalMonitorControl().stopTransmit();        }        if (remoteMonitorControl != null) {            getRemoteMonitorControl().stopReceive();        }    }    /**     * Sets the time in ms this call started     */    protected void setCallStartTime() {        this.callStartTime = System.currentTimeMillis();    }    /**     * Sets the time in ms this call ended     */    protected void setCallEndTime() {        this.callEndTime = System.currentTimeMillis();    }    /**     * Command HoldCall reveived from remote     */    private void localActionHoldCall(boolean myHold) {        getLocalMonitorControl().pauseMonitor();        getRemoteMonitorControl().pauseMonitor();    }    /**     * Command ResumeCall received from remote     */    private void localActionResumeCall() {        getLocalMonitorControl().resumeMonitor();        getRemoteMonitorControl().resumeMonitor();    }    /**     * Command EndSession received from remote     */    private void localActionEndSession() {        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("localActionEndSession");        }        if (receiveTimeoutThread != null) {            receiveTimeoutThread.stopThread();            receiveTimeoutThread = null;        }        this.stopTransmitReceive();        this.stopMonitors();    }    /**     * Called from UI signaling user accepts call invitation     */    public void viewActionAcceptCall() {        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("viewActionAcceptCall");        }        sendCommand(COMMAND_VIJXTA_START_ACCEPT, null);        setProtocolState(SESSION_VIJXTA_START_ACCEPT_SENT);        setProtocolState(SESSION_VIJXTA_INCALL);    }    /**     * Called from IU signaling user wishes to place call on hold.     */    public void viewActionHoldCall() {        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("viewActionHoldCall");        }        sendCommand(COMMAND_VIJXTA_HOLD_REQUEST, COMMAND_VIJXTA_HOLD_ACCEPT);        setProtocolState(SESSION_VIJXTA_HOLD_REQUEST_SENT);    }    /**     * Called from IU signaling user wishes to hangup call.     */    public void viewActionHangupCall() {        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("viewActionHangupCall");        }        sendCommand(COMMAND_VIJXTA_HANGUP_REQUEST, COMMAND_VIJXTA_HANGUP_ACCEPT);        setProtocolState(SESSION_VIJXTA_HANGUP_REQUEST_SENT);        this.setCallEndTime();        this.stopTransmitReceive();        this.stopMonitors();    }    /**     * Called from IU signaling user wishes to resume a call previsously placed     * on hold.     */    public void viewActionResumeCall() {        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("viewActionResumeCall");        }        sendCommand(COMMAND_VIJXTA_RESUME_REQUEST, COMMAND_VIJXTA_RESUME_ACCEPT);        setProtocolState(SESSION_VIJXTA_RESUME_REQUEST_SENT);    }    private void sendCommand(String command) {        sendCommand(command, null, null);    }    private void sendCommand(String command, String ackCommand) {        sendCommand(command, ackCommand, null);    }    /**     * Sends a command on the vijxta dialog pipe. This does not change the     * Protocol state. We have to remember to do this ourselves.     */    private void sendCommand(String command, String ackCommand, HashMap<String, MessageElement> elementMap) {        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("sendCommand : " + command);        }        DialogMessage msg = (DialogMessage) templateMessage.clone();        StringMessageElement commandElement = new StringMessageElement(                TAG_SESSION_COMMAND, command, null);        msg.addMessageElement(TAG_SESSION_COMMAND, commandElement);        if (elementMap != null) {            for (String elementName : elementMap.keySet()) {                MessageElement element = elementMap.get(elementName);                msg.addMessageElement(elementName, element);            }        }        if (ackCommand != null) {            this.messageAckThread = new MessageAckThread(ackCommand);            this.messageAckThread.start();            this.messageAckThread.waitForStart();        }        this.viJxtaDialog.dispatch(msg);    }    /**     * This method updates the current protocol state. Also signals the UI     * of a protocol state change.     */    private void setProtocolState(int protocolState) {        this.protocolState = protocolState;        if (Logging.SHOW_INFO && LOG.isLoggable(Level.INFO)) {            LOG.info("ProtocolStateChanged to " +                    this.sessionStateTable.get(new Integer(protocolState)));        }        this.viJxtaView.protocolStateChanged(protocolState);    }    /**     * Returns the protocol state     */    public int getProtocolState() {        return this.protocolState;

⌨️ 快捷键说明

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