}
protected void callbackStateChange(DispatchManager dispatchManager, ConnectionStateEnum oldState, ConnectionStateEnum newState) {
if (this.callbackSessionStateSet == null) return;
SessionName sessionName = dispatchManager.getSessionName();
/*
// Not yet implemented:
// "/event/callbackAlive" "/event/callbackPolling"
//String event = ContextNode.SEP + "event" + ContextNode.SEP + (newState.equals(ConnectionStateEnum.ALIVE)?"callbackAlive":"callbackPolling");
// "client/joe/session/1/event/callbackAlive", "client/joe/session/1/event/callbackPolling"
String foundEvent = sessionName.getRelativeName() + event;
if (!this.callbackSessionStateSet.contains(foundEvent)) {
// "client/joe/session/* /event/callbackAlive"
foundEvent = ContextNode.SUBJECT_MARKER_TAG + ContextNode.SEP + sessionName.getLoginName() + ContextNode.SEP + ContextNode.SESSION_MARKER_TAG + ContextNode.SEP + "*" + event;
if (!this.callbackSessionStateSet.contains(foundEvent)) {
// "client/* /session/* /event/callbackAlive"
foundEvent = ContextNode.SUBJECT_MARKER_TAG + ContextNode.SEP + "*" + ContextNode.SEP + ContextNode.SESSION_MARKER_TAG + ContextNode.SEP + "*" + event;
if (!this.callbackSessionStateSet.contains(foundEvent)) {
return;
}
}
}
*/
try {
//ConnectQosData cd = clientEvent.getSessionInfo().getConnectQos().getData();
//dispatchManager.getSecurityInterceptor().getConnectQos();
//dispatchManager.getDispatchConnectionsHandler().getCurrentDispatchConnection().getSessionInfoProtector().getConnectQos();
//log.severe("Debug only: lookup " + sessionName.toString());
CbDispatchConnection cbd = (CbDispatchConnection)dispatchManager.getDispatchConnectionsHandler().getCurrentDispatchConnection();
if (cbd != null) {
I_AdminSession is = cbd.getAdminSession();
ConnectQosData cd = is.getConnectQos().getData();
//ConnectQosData cd = clientEvent.getSessionInfo().getConnectQos().getData();
// A client can on connect send a event/callbackState=false clientProperty to suppress the event fired
if (cd.getClientProperty(ContextNode.EVENT_MARKER_TAG + ContextNode.SEP + "callbackState", true) == false) {
if (log.isLoggable(Level.FINE)) log.fine("Found " + ContextNode.EVENT_MARKER_TAG + ContextNode.SEP + "callbackState=true for "+sessionName.toString());
return;
}
//else
// log.severe("Debug only: Not found " + ContextNode.EVENT_MARKER_TAG + ContextNode.SEP + "callbackState");
}
}
catch (Throwable e) {
e.printStackTrace();
log.warning("Accessing connectQos failed: " + e.toString());
}
// "/event/callbackState"
String event = ContextNode.SEP + "event" + ContextNode.SEP + "callbackState";
// "client/joe/session/1/event/callbackState"
String foundEvent = sessionName.getRelativeName();
if (!this.callbackSessionStateSet.contains(foundEvent)) {
// "client/joe/session/*"
foundEvent = ContextNode.SUBJECT_MARKER_TAG + ContextNode.SEP + sessionName.getLoginName() + ContextNode.SEP + ContextNode.SESSION_MARKER_TAG + ContextNode.SEP + "*";
if (!this.callbackSessionStateSet.contains(foundEvent)) {
foundEvent = ContextNode.SUBJECT_MARKER_TAG + ContextNode.SEP + "*" + ContextNode.SEP + ContextNode.SESSION_MARKER_TAG + ContextNode.SEP + sessionName.getPublicSessionId();
// "client/*/session/1"
if (!this.callbackSessionStateSet.contains(foundEvent)) {
// "client/*/session/*"
foundEvent = ContextNode.SUBJECT_MARKER_TAG + ContextNode.SEP + "*" + ContextNode.SEP + ContextNode.SESSION_MARKER_TAG + ContextNode.SEP + "*";
if (!this.callbackSessionStateSet.contains(foundEvent)) {
return;
}
}
}
}
foundEvent += event;
try {
String summary = "Callback state has changed to "
+ newState.toString() + " for client "
+ sessionName.getAbsoluteName();
String description = (oldState.equals(newState))?
("Callback has state changed"
+ " to "+ newState.toString() + " for client "
+ sessionName.getAbsoluteName())
:
("Callback state has changed from " + oldState.toString()
+ " to "+ newState.toString() + " for client "
+ sessionName.getAbsoluteName());
String eventType = foundEvent + " " + newState.toString();
String errorCode = null;
if (this.smtpDestinationHelper != null) {
sendEmail(summary, description, eventType, null, sessionName, false);