Search in sources :

Example 1 with NullStringer

use of org.apache.openmeetings.util.NullStringer in project openmeetings by apache.

the class WbPanel method loadWhiteboards.

private StringBuilder loadWhiteboards(StringBuilder sb, Client cl, Whiteboards wbs, Set<Entry<Long, Whiteboard>> boardSet) {
    for (Entry<Long, Whiteboard> entry : boardSet) {
        Whiteboard wb = entry.getValue();
        sb.append(new StringBuilder("WbArea.create(").append(getAddWbJson(wb)).append(");"));
        JSONArray arr = new JSONArray();
        for (JSONObject o : wb.list()) {
            arr.put(addFileUrl(cl, wbs.getUid(), o));
        }
        sb.append("WbArea.load(").append(getObjWbJson(entry.getKey(), arr).toString(new NullStringer())).append(");");
    }
    return sb;
}
Also used : JSONObject(com.github.openjson.JSONObject) JSONArray(com.github.openjson.JSONArray) NullStringer(org.apache.openmeetings.util.NullStringer) Whiteboard(org.apache.openmeetings.db.dto.room.Whiteboard)

Example 2 with NullStringer

use of org.apache.openmeetings.util.NullStringer in project openmeetings by apache.

the class WbWebSocketHelper method sendWbFile.

private static void sendWbFile(Long roomId, long wbId, String ruid, JSONObject file, BaseFileItem fi, boolean publish) {
    if (publish) {
        publish(new WsMessageWbFile(roomId, wbId, ruid, file, fi));
    }
    final JSONObject _f = addFileUrl(ruid, file, fi, null);
    WebSocketHelper.sendRoom(roomId, new JSONObject().put("type", "wb"), null, (o, c) -> o.put("func", WbAction.createObj.name()).put("param", getObjWbJson(wbId, patchUrls(fi, c, _f))).toString(new NullStringer()));
}
Also used : JSONObject(com.github.openjson.JSONObject) NullStringer(org.apache.openmeetings.util.NullStringer)

Example 3 with NullStringer

use of org.apache.openmeetings.util.NullStringer 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 NullStringer

use of org.apache.openmeetings.util.NullStringer in project openmeetings by apache.

the class WbWebSocketHelper method addFileUrl.

public static JSONObject addFileUrl(String ruid, JSONObject _file, BaseFileItem fi, Client c) {
    JSONObject file = new JSONObject(_file.toString(new NullStringer()));
    final FileSystemResourceReference ref;
    final PageParameters pp = new PageParameters().add("id", fi.getId()).add("ruid", ruid).add("wuid", _file.optString("uid"));
    if (c != null) {
        pp.add("uid", c.getUid());
    }
    file.put("deleted", !fi.exists());
    switch(fi.getType()) {
        case Video:
            ref = new RoomResourceReference();
            file.put(PARAM__SRC, urlFor(ref, pp));
            file.put(PARAM__POSTER, urlFor(new RoomPreviewResourceReference(), pp));
            break;
        case Recording:
            ref = new Mp4RecordingResourceReference();
            file.put(PARAM__SRC, urlFor(ref, pp));
            file.put(PARAM__POSTER, urlFor(new PngRecordingResourceReference(), pp));
            break;
        case Presentation:
            ref = new RoomResourceReference();
            file.put(PARAM__SRC, urlFor(ref, pp));
            break;
        default:
            ref = new RoomResourceReference();
            file.put(PARAM_SRC, urlFor(ref, pp));
            break;
    }
    return file;
}
Also used : JSONObject(com.github.openjson.JSONObject) Mp4RecordingResourceReference(org.apache.openmeetings.web.user.record.Mp4RecordingResourceReference) PageParameters(org.apache.wicket.request.mapper.parameter.PageParameters) RoomResourceReference(org.apache.openmeetings.web.room.RoomResourceReference) PngRecordingResourceReference(org.apache.openmeetings.web.user.record.PngRecordingResourceReference) NullStringer(org.apache.openmeetings.util.NullStringer) RoomPreviewResourceReference(org.apache.openmeetings.web.room.RoomPreviewResourceReference) FileSystemResourceReference(org.apache.wicket.resource.FileSystemResourceReference)

Example 5 with NullStringer

use of org.apache.openmeetings.util.NullStringer in project openmeetings by apache.

the class Whiteboard method toJson.

public JSONObject toJson() {
    // deep-copy
    JSONObject json = new JSONObject(new JSONObject(this).toString(new NullStringer()));
    // filtering
    json.remove("id");
    // filtering
    json.remove("empty");
    JSONObject items = new JSONObject();
    for (Entry<String, String> e : roomItems.entrySet()) {
        JSONObject o = new JSONObject(e.getValue());
        // filtering
        if ("Clipart".equals(o.opt("omType"))) {
            if (o.has(PARAM__SRC)) {
                o.put(PARAM_SRC, o.get(PARAM__SRC));
            }
        } else {
            o.remove(PARAM_SRC);
        }
        o.remove(PARAM__SRC);
        items.put(e.getKey(), o);
    }
    json.put(ITEMS_KEY, items);
    return json;
}
Also used : JSONObject(com.github.openjson.JSONObject) NullStringer(org.apache.openmeetings.util.NullStringer)

Aggregations

JSONObject (com.github.openjson.JSONObject)5 NullStringer (org.apache.openmeetings.util.NullStringer)5 JSONArray (com.github.openjson.JSONArray)1 Whiteboard (org.apache.openmeetings.db.dto.room.Whiteboard)1 Client (org.apache.openmeetings.db.entity.basic.Client)1 RoomMessage (org.apache.openmeetings.db.util.ws.RoomMessage)1 TextRoomMessage (org.apache.openmeetings.db.util.ws.TextRoomMessage)1 RoomPreviewResourceReference (org.apache.openmeetings.web.room.RoomPreviewResourceReference)1 RoomResourceReference (org.apache.openmeetings.web.room.RoomResourceReference)1 Activity (org.apache.openmeetings.web.room.activities.Activity)1 Mp4RecordingResourceReference (org.apache.openmeetings.web.user.record.Mp4RecordingResourceReference)1 PngRecordingResourceReference (org.apache.openmeetings.web.user.record.PngRecordingResourceReference)1 IPartialPageRequestHandler (org.apache.wicket.core.request.handler.IPartialPageRequestHandler)1 WebSocketPushPayload (org.apache.wicket.protocol.ws.api.event.WebSocketPushPayload)1 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)1 FileSystemResourceReference (org.apache.wicket.resource.FileSystemResourceReference)1