use of org.jivesoftware.openfire.session.ClientSession in project Openfire by igniterealtime.
the class RayoComponent method notifyConferenceMonitors.
public void notifyConferenceMonitors(ConferenceEvent conferenceEvent) {
Log.info("RayoComponent notifyConferenceMonitors " + conferenceEvent.toString());
if (defaultIncomingConferenceId.equals(conferenceEvent.getConferenceId()))
return;
ConferenceManager conferenceManager = null;
try {
if (conferenceEvent.equals(ConferenceEvent.MEMBER_LEFT) || conferenceEvent.equals(ConferenceEvent.MEMBER_JOINED)) {
Log.info("RayoComponent notifyConferenceMonitors looking for call " + conferenceEvent.getCallId() + " " + conferenceEvent.getMemberCount());
try {
conferenceManager = ConferenceManager.findConferenceManager(conferenceEvent.getConferenceId());
} catch (Exception e) {
}
if (conferenceManager != null) {
String groupName = conferenceManager.getGroupName();
String callId = conferenceManager.getCallId();
// special case of SIP incoming
if (callId == null)
callId = conferenceEvent.getConferenceId();
CallHandler farParty = CallHandler.findCall(callId);
CallHandler callHandler = CallHandler.findCall(conferenceEvent.getCallId());
if (callHandler != null) {
Log.info("RayoComponent notifyConferenceMonitors found call handler " + callHandler + " " + farParty);
CallParticipant callParticipant = callHandler.getCallParticipant();
ArrayList memberList = conferenceManager.getMemberList();
if (conferenceEvent.equals(ConferenceEvent.MEMBER_LEFT) && callId.equals(conferenceEvent.getCallId())) {
if (// far party left
farParty != null && farParty.getCallParticipant().isHeld() == false) {
synchronized (memberList) {
for (int i = 0; i < memberList.size(); i++) {
CallHandler participant = ((ConferenceMember) memberList.get(i)).getCallHandler();
participant.cancelRequest("Far Party has left");
}
}
}
}
int memberCount = memberList.size();
if (groupName == null) {
if (isMixerMuc(conferenceEvent.getConferenceId())) {
MUCRoom room = XMPPServer.getInstance().getMultiUserChatManager().getMultiUserChatService("conference").getChatRoom(conferenceEvent.getConferenceId());
Log.info("RayoComponent notifyConferenceMonitors routing to room occupants of " + conferenceEvent.getConferenceId());
for (MUCRole role : room.getOccupants()) {
String jid = role.getUserAddress().toString();
Log.info("RayoComponent notifyConferenceMonitors routing to room occupant " + jid);
Presence presence = new Presence();
presence.setFrom(conferenceEvent.getCallId() + "@" + getDomain());
presence.setTo(jid);
if (conferenceEvent.equals(ConferenceEvent.MEMBER_LEFT)) {
UnjoinedEvent event = new UnjoinedEvent(null, conferenceEvent.getConferenceId(), JoinDestinationType.MIXER);
presence.getElement().add(rayoProvider.toXML(event));
} else {
JoinedEvent event = new JoinedEvent(null, conferenceEvent.getConferenceId(), JoinDestinationType.MIXER);
presence.getElement().add(rayoProvider.toXML(event));
}
sendPacket(presence);
}
} else {
Log.info("RayoComponent notifyConferenceMonitors routing to owner " + callParticipant.getCallOwner() + " " + memberCount);
routeJoinEvent(callParticipant.getCallOwner(), callParticipant, conferenceEvent, memberCount, groupName, callId, farParty, conferenceManager);
}
} else {
Group group = GroupManager.getInstance().getGroup(groupName);
for (JID memberJID : group.getMembers()) {
Collection<ClientSession> sessions = SessionManager.getInstance().getSessions(memberJID.getNode());
for (ClientSession session : sessions) {
routeJoinEvent(session.getAddress().toString(), callParticipant, conferenceEvent, memberCount, groupName, callId, farParty, conferenceManager);
}
}
}
if (memberCount == 0 && conferenceEvent.equals(ConferenceEvent.MEMBER_LEFT)) {
conferenceManager.recordConference(false, null, null);
conferenceManager.endConference(conferenceEvent.getConferenceId());
CallParticipant heldCall = conferenceManager.getHeldCall();
if (heldCall != null) {
JID target = getJID(heldCall.getCallId());
if (target != null) {
Presence presence = new Presence();
presence.setFrom(callId + "@" + getDomain());
presence.setTo(target);
presence.getElement().add(rayoProvider.toXML(new EndEvent(null, EndEvent.Reason.valueOf("HANGUP"), callParticipant.getHeaders())));
sendPacket(presence);
}
}
} else if (memberCount == 2) {
// reset after informing on redirect
conferenceManager.setTransferCall(false);
}
}
}
}
} catch (Exception e) {
Log.error("RayoComponent Error in notifyConferenceMonitors " + e);
e.printStackTrace();
}
}
use of org.jivesoftware.openfire.session.ClientSession in project Openfire by igniterealtime.
the class RayoComponent method findUser.
private JID findUser(String username) {
Collection<ClientSession> sessions = SessionManager.getInstance().getSessions();
JID foundUser = null;
for (ClientSession session : sessions) {
try {
String userId = session.getAddress().getNode();
if (username.equals(userId)) {
Log.info("Incoming SIP, findUser " + session.getAddress());
foundUser = session.getAddress();
break;
}
} catch (Exception e) {
}
}
return foundUser;
}
use of org.jivesoftware.openfire.session.ClientSession in project Openfire by igniterealtime.
the class SessionController method getUserSessions.
/**
* Gets the user sessions.
*
* @param username the username
* @return the user sessions
* @throws ServiceException the service exception
*/
public SessionEntities getUserSessions(String username) throws ServiceException {
Collection<ClientSession> clientSessions = SessionManager.getInstance().getSessions(username);
SessionEntities sessionEntities = convertToSessionEntities(clientSessions);
return sessionEntities;
}
use of org.jivesoftware.openfire.session.ClientSession in project Openfire by igniterealtime.
the class UserServiceController method disableUser.
/**
* Disable user.
*
* @param username
* the username
* @throws ServiceException
* the service exception
*/
public void disableUser(String username) throws ServiceException {
getAndCheckUser(username);
lockOutManager.disableAccount(username, null, null);
if (lockOutManager.isAccountDisabled(username)) {
final StreamError error = new StreamError(StreamError.Condition.not_authorized);
for (ClientSession sess : SessionManager.getInstance().getSessions(username)) {
sess.deliverRawText(error.toXML());
sess.close();
}
}
}
Aggregations