📄 eventsink.java
字号:
public void OnCallEstablished(Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
m_appFrame.LogEvent("OnCallEstablished", rArguments);
} // OnCallEstablished
///////////////////////////////////////////////////////////////////////////
/**
* Notification that a call has been put on Hold
*/
///////////////////////////////////////////////////////////////////////////
public void OnCallHeld(Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
m_appFrame.LogEvent("OnCallHeld", rArguments);
} // OnCallHeld
///////////////////////////////////////////////////////////////////////////
/**
* Notification that a call has been retrieved from Hold.
*/
///////////////////////////////////////////////////////////////////////////
public void OnCallRetrieved(Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
m_appFrame.LogEvent("OnCallRetrieved", rArguments);
} // OnCallRetrieved
///////////////////////////////////////////////////////////////////////////
/**
* Notification that our connection to a call cleared. Ex. we hang up
* on a Conference Call.
*/
///////////////////////////////////////////////////////////////////////////
public void OnCallConnectionCleared(Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
m_appFrame.LogEvent("OnCallConnectionCleared", rArguments);
} // OnCallConnectionCleared
///////////////////////////////////////////////////////////////////////////
/**
* Notification that a call was transferred.
*/
///////////////////////////////////////////////////////////////////////////
public void OnCallTransferred(Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
m_appFrame.LogEvent("OnCallTransfered", rArguments);
DisplayCallInfo(rArguments);
} // OnCallTransferred
///////////////////////////////////////////////////////////////////////////
/**
* Notification that a call was conferenced.
*/
///////////////////////////////////////////////////////////////////////////
public void OnCallConferenced(Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
m_appFrame.LogEvent("OnCallConferenced", rArguments);
DisplayCallInfo(rArguments);
} // OnCallConferenced
///////////////////////////////////////////////////////////////////////////
/**
* Notification from the server that button enablement changed. The
* enablement mask is a critical piece of information because it informs
* us of what functionality is currently allowed and what is not. The
* mask allows our code to be ACD independent since the server uses it to
* inform us of what is and is not allowed.
*/
///////////////////////////////////////////////////////////////////////////
public void OnButtonEnablementChange(Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
m_appFrame.LogEvent("OnButtonEnablementChange", rArguments);
// Get mask from message
Long LMask = rArguments.GetValueUIntObj(CTIOS_ENABLEMENTMASK);
if (null==LMask)
return;
final long bitMask = LMask.longValue();
// Transfer modifacation of the GUI objects to the EventDispatchThread
// or we could have a thread sync issue. We're currently on the
// CtiOsSession's event thread
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
// Enable a button if it's bit is turned on. Disable it if not.
m_appFrame.m_btnAnswer.setEnabled( ((bitMask & ENABLE_ANSWER) > 0));
m_appFrame.m_btnConference.setEnabled( ((bitMask & ENABLE_CONFERENCE_COMPLETE) > 0));
m_appFrame.m_btnCCConference.setEnabled( ((bitMask & ENABLE_CONFERENCE_INIT) > 0));
m_appFrame.m_btnHold.setEnabled( ((bitMask & ENABLE_HOLD) > 0));
m_appFrame.m_btnLogin.setEnabled( ((bitMask & ENABLE_LOGIN) > 0));
m_appFrame.m_btnLogout.setEnabled( ((bitMask & (ENABLE_LOGOUT | CtiOs_Enums.ButtonEnablement.ENABLE_LOGOUT_WITH_REASON)) > 0));
m_appFrame.m_btnMakeCall.setEnabled( ((bitMask & ENABLE_MAKECALL) > 0));
m_appFrame.m_btnNotReady.setEnabled( ((bitMask & (ENABLE_NOTREADY | CtiOs_Enums.ButtonEnablement.ENABLE_NOTREADY_WITH_REASON)) > 0));
m_appFrame.m_btnReady.setEnabled( ((bitMask & ENABLE_READY) > 0));
m_appFrame.m_btnRelease.setEnabled( ((bitMask & ENABLE_RELEASE) > 0));
m_appFrame.m_btnRetrieve.setEnabled( ((bitMask & ENABLE_RETRIEVE) > 0));
m_appFrame.m_btnSSTransfer.setEnabled( ((bitMask & ENABLE_SINGLE_STEP_TRANSFER) > 0));
m_appFrame.m_btnSSConference.setEnabled( ((bitMask & ENABLE_SINGLE_STEP_CONFERENCE) > 0));
m_appFrame.m_btnTransfer.setEnabled( ((bitMask & ENABLE_TRANSFER_COMPLETE) > 0));
m_appFrame.m_btnCCTransfer.setEnabled( ((bitMask & ENABLE_TRANSFER_INIT) > 0));
}
});
} // OnButtonEnablementChange
///////////////////////////////////////////////////////////////////////////
/**
* Confirmation from the server that the Session has been placed in Agent
* mode.
*/
///////////////////////////////////////////////////////////////////////////
public void OnSetAgentModeEvent(Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
m_appFrame.LogEvent("OnSetAgentModeEvent", rArguments);
// Get a reference to the Agent object
Agent ctiAgent = m_appFrame.GetAgent();
if (null == ctiAgent)
{
m_appFrame.Log("ERROR: Unable to determine current agent. Aborting login");
return;
}
// If we haven't logged in yet, then do so now.
// SetAgent triggers a QueryAgentStateReq which generates this conf. We assume that if
// we have not yet logged in, this conf is the result of a call to SetAgent.
if ( ! IsLoginPending() )
{
SetLoginPending(true);
// Retrieve our login parameters and login
Arguments rArgLogAgent = new Arguments();
int iPeriphID = m_appFrame.GetPeripheralID();
if (iPeriphID != 0)
{
rArgLogAgent.SetValue(CTIOS_PERIPHERALID, iPeriphID);
}
String sAgentID = m_appFrame.GetAgentID();
if ( (sAgentID != null) && sAgentID.length() > 0)
{
rArgLogAgent.SetValue(CTIOS_AGENTID, sAgentID);
}
String sPassword = m_appFrame.GetAgentPassword();
if ( (sPassword != null) && sPassword.length() > 0)
{
rArgLogAgent.SetValue(CTIOS_AGENTPASSWORD, sPassword);
}
String sInstrument = m_appFrame.GetAgentInstrument();
if ( (sInstrument != null) && sInstrument.length() > 0)
{
rArgLogAgent.SetValue(CTIOS_AGENTINSTRUMENT, sInstrument);
}
String sExtension = m_appFrame.GetAgentExtension();
if ( (sExtension != null) && sExtension.length() > 0)
{
rArgLogAgent.SetValue(CTIOS_AGENTEXTENSION, sExtension);
}
rArgLogAgent.SetValue(CTIOS_AUTOLOGIN, 1 );
// Make the login request. This event came in response to a
// SetAgent call which was made in the Login button click
// event handler. We needed to wait until we got this
// CONF event to request the actual login.
ctiAgent.Login(rArgLogAgent);
}
} // OnSetAgentModeEvent
///////////////////////////////////////////////////////////////////////////
/**
* Notification that a request failed for some reason.
*/
///////////////////////////////////////////////////////////////////////////
public void OnControlFailureConf (Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
// If we failed on a Login, reenable the button and reset
// the login-in-progress flag
if (m_appFrame.IsLoginInProgress())
{
m_appFrame.SetLoginInProgress(false);
}
m_appFrame.LogEvent("OnControlFailureConf", rArguments);
} // OnControlFailureConf
///////////////////////////////////////////////////////////////////////////
/**
* Failure event.
*/
///////////////////////////////////////////////////////////////////////////
public void OnFailure(Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
// If we failed on a Login, reenable the button and reset
// the login-in-progress flag
if (m_appFrame.IsLoginInProgress())
{
m_appFrame.SetLoginInProgress(false);
}
m_appFrame.LogEvent("OnFailure", rArguments);
} // OnFailure
///////////////////////////////////////////////////////////////////////////
/**
* Failure event.
*/
///////////////////////////////////////////////////////////////////////////
public void OnFailureConf(Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
// If we failed on a Login, reenable the button and reset
// the login-in-progress flag
if (m_appFrame.IsLoginInProgress())
{
m_appFrame.SetLoginInProgress(false);
}
m_appFrame.LogEvent("OnFailureConf", rArguments);
} // OnFailureConf
///////////////////////////////////////////////////////////////////////////
/**
* Notification that a Call failed for some reason.
*/
///////////////////////////////////////////////////////////////////////////
public void OnCallFailed (Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
m_appFrame.LogEvent("OnCallFailed", rArguments);
} // OnCallFailed
///////////////////////////////////////////////////////////////////////////
/**
* Notification from the server which is NOT always a failure or error. It
* is sometimes used to report status.
*/
///////////////////////////////////////////////////////////////////////////
public void OnCTIOSFailure (Arguments rArguments)
{
if (IsMonitoredEvent(rArguments))
return;
if (rArguments.IsValid(CtiOs_IKeywordIDs.CTIOS_ERRORMESSAGE))
{
m_appFrame.LogEvent("OnCTIOSFailure", rArguments);
// If we failed on a Login, reenable the button and reset
// the login-in-progress flag
if (m_appFrame.IsLoginInProgress())
{
m_appFrame.SetLoginInProgress(false);
}
return;
}
String sMsg = rArguments.GetValueString(CtiOs_IKeywordIDs.CTIOS_STATUSBARMESSAGE);
if (null != sMsg )
{
m_appFrame.Log(sMsg);
}
} // OnCTIOSFailure
///////////////////////////////////////////////////////////////////////////
/**
* Check to see if it's a monitored event.
*/
///////////////////////////////////////////////////////////////////////////
public boolean IsMonitoredEvent(Arguments rArguments)
{
Boolean BMonitored = rArguments.GetValueBoolObj(CtiOs_IKeywordIDs.CTIOS_MONITORED);
if (null != BMonitored && BMonitored.booleanValue()==true)
return true;
return false;
} // IsMonitoredEvent
///////////////////////////////////////////////////////////////////////////
/**
* Check to see if we have a Login in progress.
*/
///////////////////////////////////////////////////////////////////////////
public boolean IsLoginPending()
{
synchronized(m_cs)
{
return m_bLoginPending;
}
} // IsLoginPending
///////////////////////////////////////////////////////////////////////////
/**
* Set flag indicating if we have a Login in progress.
*/
///////////////////////////////////////////////////////////////////////////
public void SetLoginPending(boolean bLoginPending)
{
synchronized(m_cs)
{
m_bLoginPending = bLoginPending;
}
} // SetLoginPending
///////////////////////////////////////////////////////////////////////////
/**
* Disabled all UI buttons.
*/
///////////////////////////////////////////////////////////////////////////
public void DisableAllButtons()
{
// Transfer modifacation of the GUI objects to the EventDispatchThread
// or we could have a thread sync issue. We're currently on the
// CtiOsSession's event thread
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
m_appFrame.m_btnLogin.setEnabled(false);
m_appFrame.m_btnLogout.setEnabled(false);
m_appFrame.m_btnReady.setEnabled(false);
m_appFrame.m_btnNotReady.setEnabled(false);
m_appFrame.m_btnMakeCall.setEnabled(false);
m_appFrame.m_btnAnswer.setEnabled(false);
m_appFrame.m_btnRelease.setEnabled(false);
m_appFrame.m_btnHold.setEnabled(false);
m_appFrame.m_btnRetrieve.setEnabled(false);
m_appFrame.m_btnCCConference.setEnabled(false);
m_appFrame.m_btnConference.setEnabled(false);
m_appFrame.m_btnSSConference.setEnabled(false);
m_appFrame.m_btnCCTransfer.setEnabled(false);
m_appFrame.m_btnTransfer.setEnabled(false);
m_appFrame.m_btnSSTransfer.setEnabled(false);
}
});
} // DisableAllButtons
///////////////////////////////////////////////////////////////////////////
/**
* Writes call information to the Log Window
*/
///////////////////////////////////////////////////////////////////////////
public void DisplayCallInfo(final Arguments rArguments)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
// Check if Call Variable 1 is present and, if so, write it
// in the CallVariable1 text field
String sValue = rArguments.GetValueString(CTIOS_CALLVARIABLE1);
if (sValue != null)
{
m_appFrame.m_edtCallVariable1.setText(sValue);
}
// Get the Unique Object ID of the call and display it in
// the CallID text field
sValue = rArguments.GetValueString(CTIOS_UNIQUEOBJECTID);
if (sValue != null)
{
m_appFrame.m_edtCallID.setText(sValue);
}
}
});
} // DisplayCallInfo
} // class EventSink
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -