Search in sources :

Example 1 with RoomMessage

use of org.apache.openmeetings.db.util.ws.RoomMessage in project openmeetings by apache.

the class PollResultsDialog method onInitialize.

@Override
protected void onInitialize() {
    getTitle().setObject(getString("37"));
    cancel = new DialogButton("cancel", getString("lbl.cancel"));
    close = new DialogButton("close", getString("1418"));
    delete = new DialogButton("delete", getString("1420"));
    add(closeConfirm = new MessageDialog("closeConfirm", getString("1418"), getString("1419"), DialogButtons.YES_NO, DialogIcon.WARN) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
            if (button != null && button.match(YES)) {
                Long id = dispForm.getModelObject().getId();
                pollDao.close(roomId);
                selForm.updateModel(handler);
                RoomPoll p = pollDao.get(id);
                selForm.select.setModelObject(p);
                dispForm.updateModel(p, true, handler);
                sendRoom(new RoomMessage(roomId, findParent(MainPanel.class).getClient(), RoomMessage.Type.pollUpdated));
            }
        }
    });
    add(deleteConfirm = new MessageDialog("deleteConfirm", getString("1420"), getString("1421"), DialogButtons.YES_NO, DialogIcon.WARN) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
            if (button != null && button.match(YES)) {
                pollDao.delete(dispForm.getModelObject());
                selForm.updateModel(handler);
                dispForm.updateModel(selForm.select.getModelObject(), true, handler);
                sendRoom(new RoomMessage(roomId, findParent(MainPanel.class).getClient(), RoomMessage.Type.pollUpdated));
            }
        }
    });
    super.onInitialize();
}
Also used : DialogButton(com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton) MainPanel(org.apache.openmeetings.web.common.MainPanel) RoomMessage(org.apache.openmeetings.db.util.ws.RoomMessage) IPartialPageRequestHandler(org.apache.wicket.core.request.handler.IPartialPageRequestHandler) MessageDialog(com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog) RoomPoll(org.apache.openmeetings.db.entity.room.RoomPoll)

Example 2 with RoomMessage

use of org.apache.openmeetings.db.util.ws.RoomMessage in project openmeetings by apache.

the class CreatePollDialog method onSubmit.

@Override
protected void onSubmit(AjaxRequestTarget target) {
    pollDao.close(roomId);
    pollDao.update(form.getModelObject());
    sendRoom(new RoomMessage(roomId, findParent(MainPanel.class).getClient(), RoomMessage.Type.pollCreated));
}
Also used : MainPanel(org.apache.openmeetings.web.common.MainPanel) RoomMessage(org.apache.openmeetings.db.util.ws.RoomMessage)

Example 3 with RoomMessage

use of org.apache.openmeetings.db.util.ws.RoomMessage in project openmeetings by apache.

the class RoomPanel method onEvent.

@Override
public void onEvent(IEvent<?> event) {
    Client _c = getClient();
    if (_c != null && event.getPayload() instanceof WebSocketPushPayload) {
        WebSocketPushPayload wsEvent = (WebSocketPushPayload) event.getPayload();
        if (wsEvent.getMessage() instanceof RoomMessage) {
            RoomMessage m = (RoomMessage) wsEvent.getMessage();
            IPartialPageRequestHandler handler = wsEvent.getHandler();
            switch(m.getType()) {
                case pollCreated:
                    menu.updatePoll(handler, m.getUserId());
                    break;
                case pollUpdated:
                    menu.updatePoll(handler, null);
                    break;
                case recordingStoped:
                    {
                        String uid = ((TextRoomMessage) m).getText();
                        Client c = cm.getBySid(uid);
                        if (c == null) {
                            log.error("Not existing/BAD user has stopped recording {} != {} !!!!", uid);
                            return;
                        }
                        recordingUser = null;
                        cm.update(c.remove(Client.Activity.record));
                        menu.update(handler);
                        updateInterviewRecordingButtons(handler);
                    }
                    break;
                case recordingStarted:
                    {
                        JSONObject obj = new JSONObject(((TextRoomMessage) m).getText());
                        String sid = obj.getString("sid");
                        Client c = cm.getBySid(sid);
                        if (c == null) {
                            log.error("Not existing user has started recording {} !!!!", sid);
                            return;
                        }
                        recordingUser = sid;
                        cm.update(c.set(Client.Activity.record));
                        menu.update(handler);
                        updateInterviewRecordingButtons(handler);
                    }
                    break;
                case sharingStoped:
                    {
                        JSONObject obj = new JSONObject(((TextRoomMessage) m).getText());
                        String uid = obj.getString("uid");
                        Client c = cm.getBySid(obj.getString("sid"));
                        if (c == null) {
                            log.error("Not existing user has started sharing {} !!!!", obj);
                            return;
                        }
                        handler.appendJavaScript(String.format("VideoManager.close('%s', true);", uid));
                        sharingUser = null;
                        cm.update(c.removeStream(uid).remove(Client.Activity.share));
                        menu.update(handler);
                    }
                    break;
                case sharingStarted:
                    {
                        String uid = ((TextRoomMessage) m).getText();
                        Client c = cm.get(uid);
                        if (c == null) {
                            log.error("Not existing user has started sharing {} !!!!", uid);
                            return;
                        }
                        sharingUser = uid;
                        cm.update(c.set(Client.Activity.share));
                        menu.update(handler);
                    }
                    break;
                case rightUpdated:
                    {
                        String uid = ((TextRoomMessage) m).getText();
                        Client c = cm.get(uid);
                        if (c == null) {
                            log.error("Not existing user in rightUpdated {} !!!!", uid);
                            return;
                        }
                        boolean self = _c.getUid().equals(c.getUid());
                        handler.appendJavaScript(String.format("VideoManager.update(%s);", c.streamJson(_c.getSid(), self, scm).toString(new NullStringer())));
                        sidebar.update(handler);
                        menu.update(handler);
                        wb.update(handler);
                        updateInterviewRecordingButtons(handler);
                    }
                    break;
                case newStream:
                    {
                        JSONObject obj = new JSONObject(((TextRoomMessage) m).getText());
                        String uid = obj.getString("uid");
                        Client c = cm.get(uid);
                        if (c == null) {
                            // screen client, ext video stream
                            c = cm.getBySid(obj.getString("sid"));
                        }
                        if (c == null) {
                            log.error("Not existing user in newStream {} !!!!", uid);
                            return;
                        }
                        boolean self = _c.getSid().equals(c.getSid());
                        if (!self || Client.Type.room != scm.get(uid).getType()) {
                            // stream from others or self external video
                            JSONObject jo = videoJson(c, _c.getSid(), uid);
                            handler.appendJavaScript(String.format("VideoManager.play(%s);", jo));
                        }
                        if (self) {
                            cm.update(c.addStream(uid));
                        }
                        updateInterviewRecordingButtons(handler);
                    }
                    break;
                case closeStream:
                    {
                        JSONObject obj = new JSONObject(((TextRoomMessage) m).getText());
                        String uid = obj.getString("uid");
                        Client c = cm.getBySid(obj.getString("sid"));
                        if (c != null) {
                            // c == null means client exits the room
                            if (_c.getUid().equals(c.getUid())) {
                                cm.update(c.removeStream(uid));
                            }
                        }
                        handler.appendJavaScript(String.format("VideoManager.close('%s');", uid));
                        updateInterviewRecordingButtons(handler);
                    }
                    break;
                case roomEnter:
                    sidebar.update(handler);
                    menu.update(handler);
                    sidebar.addActivity(new Activity(m, Activity.Type.roomEnter), handler);
                    break;
                case roomExit:
                    sidebar.update(handler);
                    sidebar.addActivity(new Activity(m, Activity.Type.roomExit), handler);
                    break;
                case roomClosed:
                    handler.add(room.setVisible(false));
                    roomClosed.open(handler);
                    break;
                case requestRightModerator:
                    sidebar.addActivity(new Activity((TextRoomMessage) m, Activity.Type.reqRightModerator), handler);
                    break;
                case requestRightPresenter:
                    sidebar.addActivity(new Activity((TextRoomMessage) m, Activity.Type.reqRightPresenter), handler);
                    break;
                case requestRightWb:
                    sidebar.addActivity(new Activity((TextRoomMessage) m, Activity.Type.reqRightWb), handler);
                    break;
                case requestRightShare:
                    sidebar.addActivity(new Activity((TextRoomMessage) m, Activity.Type.reqRightShare), handler);
                    break;
                case requestRightRemote:
                    sidebar.addActivity(new Activity((TextRoomMessage) m, Activity.Type.reqRightRemote), handler);
                    break;
                case requestRightA:
                    sidebar.addActivity(new Activity((TextRoomMessage) m, Activity.Type.reqRightA), handler);
                    break;
                case requestRightAv:
                    sidebar.addActivity(new Activity((TextRoomMessage) m, Activity.Type.reqRightAv), handler);
                    break;
                case requestRightMute:
                    sidebar.addActivity(new Activity((TextRoomMessage) m, Activity.Type.reqRightMute), handler);
                    break;
                case requestRightExclusive:
                    sidebar.addActivity(new Activity((TextRoomMessage) m, Activity.Type.reqRightExclusive), handler);
                    break;
                case activityRemove:
                    sidebar.removeActivity(((TextRoomMessage) m).getText(), handler);
                    break;
                case haveQuestion:
                    if (_c.hasRight(Room.Right.moderator) || getUserId().equals(m.getUserId())) {
                        sidebar.addActivity(new Activity((TextRoomMessage) m, Activity.Type.haveQuestion), handler);
                    }
                    break;
                case kick:
                    {
                        String uid = ((TextRoomMessage) m).getText();
                        if (_c.getUid().equals(uid)) {
                            handler.add(room.setVisible(false));
                            getMainPanel().getChat().toggle(handler, false);
                            clientKicked.open(handler);
                            cm.exitRoom(_c);
                        }
                    }
                    break;
                case mute:
                    {
                        JSONObject obj = new JSONObject(((TextRoomMessage) m).getText());
                        Client c = cm.getBySid(obj.getString("sid"));
                        if (c == null) {
                            log.error("Not existing user in mute {} !!!!", obj);
                            return;
                        }
                        if (!_c.getUid().equals(c.getUid())) {
                            handler.appendJavaScript(String.format("if (typeof(VideoManager) !== 'undefined') {VideoManager.mute('%s', %s);}", obj.getString("uid"), obj.getBoolean("mute")));
                        }
                    }
                    break;
                case exclusive:
                    {
                        String uid = ((TextRoomMessage) m).getText();
                        Client c = cm.get(uid);
                        if (c == null) {
                            // no luck
                            return;
                        }
                        handler.appendJavaScript(String.format("if (typeof(VideoManager) !== 'undefined') {VideoManager.exclusive('%s');}", uid));
                    }
                    break;
                case quickPollUpdated:
                    {
                        menu.update(handler);
                        handler.appendJavaScript(getQuickPollJs());
                    }
                    break;
            }
        }
    }
    super.onEvent(event);
}
Also used : JSONObject(com.github.openjson.JSONObject) TextRoomMessage(org.apache.openmeetings.db.util.ws.TextRoomMessage) RoomMessage(org.apache.openmeetings.db.util.ws.RoomMessage) IPartialPageRequestHandler(org.apache.wicket.core.request.handler.IPartialPageRequestHandler) Activity(org.apache.openmeetings.web.room.activities.Activity) WebSocketPushPayload(org.apache.wicket.protocol.ws.api.event.WebSocketPushPayload) Client(org.apache.openmeetings.db.entity.basic.Client) TextRoomMessage(org.apache.openmeetings.db.util.ws.TextRoomMessage) NullStringer(org.apache.openmeetings.util.NullStringer)

Example 4 with RoomMessage

use of org.apache.openmeetings.db.util.ws.RoomMessage in project openmeetings by apache.

the class VoteDialog method onSubmit.

/* (non-Javadoc)
	 * @see com.googlecode.wicket.jquery.ui.widget.dialog.AbstractFormDialog#onSubmit(org.apache.wicket.ajax.AjaxRequestTarget)
	 */
@Override
protected void onSubmit(AjaxRequestTarget target) {
    RoomPollAnswer a = form.getModelObject();
    Long roomId = a.getRoomPoll().getRoom().getId();
    if (!pollDao.hasVoted(roomId, getUserId())) {
        a.setVoteDate(new Date());
        a.getRoomPoll().getAnswers().add(a);
        pollDao.update(a.getRoomPoll());
    }
    sendRoom(new RoomMessage(roomId, findParent(MainPanel.class).getClient(), RoomMessage.Type.pollUpdated));
}
Also used : MainPanel(org.apache.openmeetings.web.common.MainPanel) RoomMessage(org.apache.openmeetings.db.util.ws.RoomMessage) RoomPollAnswer(org.apache.openmeetings.db.entity.room.RoomPollAnswer) Date(java.util.Date)

Example 5 with RoomMessage

use of org.apache.openmeetings.db.util.ws.RoomMessage in project openmeetings by apache.

the class ClientManager method exitRoom.

public void exitRoom(IClient c) {
    Long roomId = c.getRoomId();
    removeFromRoom(c);
    if (roomId != null) {
        sendRoom(new RoomMessage(roomId, c, RoomMessage.Type.roomExit));
        confLogDao.add(ConferenceLog.Type.roomLeave, c.getUserId(), "0", roomId, c.getRemoteAddress(), String.valueOf(roomId));
    }
}
Also used : RoomMessage(org.apache.openmeetings.db.util.ws.RoomMessage)

Aggregations

RoomMessage (org.apache.openmeetings.db.util.ws.RoomMessage)7 MainPanel (org.apache.openmeetings.web.common.MainPanel)3 Client (org.apache.openmeetings.db.entity.basic.Client)2 IPartialPageRequestHandler (org.apache.wicket.core.request.handler.IPartialPageRequestHandler)2 JSONObject (com.github.openjson.JSONObject)1 DialogButton (com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton)1 MessageDialog (com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog)1 Date (java.util.Date)1 WebMethod (javax.jws.WebMethod)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 ServiceResult (org.apache.openmeetings.db.dto.basic.ServiceResult)1 IClient (org.apache.openmeetings.db.entity.basic.IClient)1 Room (org.apache.openmeetings.db.entity.room.Room)1 RoomPoll (org.apache.openmeetings.db.entity.room.RoomPoll)1 RoomPollAnswer (org.apache.openmeetings.db.entity.room.RoomPollAnswer)1 StreamClient (org.apache.openmeetings.db.entity.room.StreamClient)1 Sessiondata (org.apache.openmeetings.db.entity.server.Sessiondata)1 User (org.apache.openmeetings.db.entity.user.User)1 TextRoomMessage (org.apache.openmeetings.db.util.ws.TextRoomMessage)1