Search in sources :

Example 6 with JSONObject

use of com.github.openjson.JSONObject in project openmeetings by apache.

the class KRoom method broadcast.

private static void broadcast(final KurentoHandler h, KUser user) {
    final JSONObject msg = newKurentoMsg();
    msg.put("id", "broadcast");
    log.debug("User {}: has started broadcast", user.getUid());
    h.sendClient(user.getUid(), msg);
}
Also used : JSONObject(com.github.openjson.JSONObject)

Example 7 with JSONObject

use of com.github.openjson.JSONObject in project openmeetings by apache.

the class KUser method getEndpointForUser.

private WebRtcEndpoint getEndpointForUser(final KurentoHandler h, final KUser sender) {
    if (sender.getUid().equals(uid)) {
        log.debug("PARTICIPANT {}: configuring loopback", this.uid);
        return outgoingMedia;
    }
    log.debug("PARTICIPANT {}: receiving video from {}", this.uid, sender.getUid());
    WebRtcEndpoint incoming = incomingMedia.get(sender.getUid());
    if (incoming == null) {
        log.debug("PARTICIPANT {}: creating new endpoint for {}", this.uid, sender.getUid());
        incoming = new WebRtcEndpoint.Builder(pipeline).build();
        incoming.addIceCandidateFoundListener(new EventListener<IceCandidateFoundEvent>() {

            @Override
            public void onEvent(IceCandidateFoundEvent event) {
                JSONObject response = newKurentoMsg();
                response.put("id", "iceCandidate");
                response.put("uid", sender.getUid());
                response.put("candidate", convert(JsonUtils.toJsonObject(event.getCandidate())));
                h.sendClient(uid, response);
            }
        });
        incomingMedia.put(sender.getUid(), incoming);
    }
    log.debug("PARTICIPANT {}: obtained endpoint for {}", this.uid, sender.getUid());
    sender.getOutgoingWebRtcPeer().connect(incoming);
    return incoming;
}
Also used : WebRtcEndpoint(org.kurento.client.WebRtcEndpoint) JSONObject(com.github.openjson.JSONObject) IceCandidateFoundEvent(org.kurento.client.IceCandidateFoundEvent)

Example 8 with JSONObject

use of com.github.openjson.JSONObject in project openmeetings by apache.

the class Client method toJson.

public JSONObject toJson(boolean self) {
    JSONObject u = new JSONObject();
    if (user != null) {
        JSONObject a = new JSONObject();
        u.put("id", user.getId()).put("firstName", user.getFirstname()).put("lastName", user.getLastname()).put("address", a);
        if (user.getAddress() != null) {
            if (Strings.isEmpty(user.getFirstname()) && Strings.isEmpty(user.getLastname())) {
                a.put("email", user.getAddress().getEmail());
            }
            a.put("country", user.getAddress().getCountry());
        }
    }
    JSONObject json = new JSONObject().put("user", u).put("cuid", uid).put("uid", uid).put("rights", new JSONArray(rights)).put("activities", new JSONArray(activities)).put("pod", pod).put("width", width).put("height", height).put("self", self);
    if (self) {
        json.put("cam", cam).put("mic", mic);
    }
    return json;
}
Also used : JSONObject(com.github.openjson.JSONObject) JSONArray(com.github.openjson.JSONArray)

Example 9 with JSONObject

use of com.github.openjson.JSONObject in project openmeetings by apache.

the class ActivitiesPanel method add.

public void add(Activity a, IPartialPageRequestHandler handler) {
    if (!isVisible()) {
        return;
    }
    activities.put(a.getId(), a);
    String text = "";
    final boolean self = getUserId().equals(a.getSender());
    final String name = self ? getString("1362") : a.getName();
    final String fmt = ((BasePage) getPage()).isRtl() ? ACTIVITY_FMT_RTL : ACTIVITY_FMT;
    switch(a.getType()) {
        case roomEnter:
            text = String.format(fmt, name, getString("activities.msg.enter"), df.format(a.getCreated()));
            break;
        case roomExit:
            text = String.format(fmt, name, getString("activities.msg.exit"), df.format(a.getCreated()));
            break;
        case reqRightModerator:
            text = String.format(fmt, name, getString("room.action.request.right.moderator"), df.format(a.getCreated()));
            break;
        case reqRightPresenter:
            text = String.format(fmt, name, getString("right.presenter.request"), df.format(a.getCreated()));
            break;
        case reqRightWb:
            text = String.format(fmt, name, getString("694"), df.format(a.getCreated()));
            break;
        case reqRightShare:
            text = String.format(fmt, name, getString("1070"), df.format(a.getCreated()));
            break;
        case reqRightRemote:
            text = String.format(fmt, name, getString("1082"), df.format(a.getCreated()));
            break;
        case reqRightA:
            text = String.format(fmt, name, getString("1603"), df.format(a.getCreated()));
            break;
        case reqRightAv:
            text = String.format(fmt, name, getString("695"), df.format(a.getCreated()));
            break;
        case reqRightMute:
            text = String.format(fmt, name, getString("1399"), df.format(a.getCreated()));
            break;
        case reqRightExclusive:
            text = String.format(fmt, name, getString("1427"), df.format(a.getCreated()));
            break;
        case haveQuestion:
            text = String.format(fmt, name, getString("693"), df.format(a.getCreated()));
            break;
    }
    final JSONObject aobj = new JSONObject().put("id", a.getId()).put("uid", a.getUid()).put("cssClass", getClass(a)).put("text", text).put("find", false);
    switch(a.getType()) {
        case reqRightModerator:
        case reqRightPresenter:
        case reqRightWb:
        case reqRightShare:
        case reqRightRemote:
        case reqRightA:
        case reqRightAv:
        case reqRightMute:
        case reqRightExclusive:
            aobj.put("accept", room.getClient().hasRight(Right.moderator));
            aobj.put("decline", room.getClient().hasRight(Right.moderator));
            break;
        case haveQuestion:
            aobj.put("find", !self);
        case roomEnter:
        case roomExit:
            aobj.put("accept", false);
            aobj.put("decline", false);
            break;
    }
    handler.appendJavaScript(new StringBuilder("Activities.add(").append(aobj.toString()).append(");"));
}
Also used : JSONObject(com.github.openjson.JSONObject)

Example 10 with JSONObject

use of com.github.openjson.JSONObject in project openmeetings by apache.

the class StartSharingButton method onClick.

@Override
public void onClick(AjaxRequestTarget target) {
    try (InputStream jnlp = getClass().getClassLoader().getResourceAsStream("APPLICATION.jnlp")) {
        app = IOUtils.toString(jnlp, UTF_8);
        Client c = cm.get(uid);
        String sid = c.getSid();
        Long roomId = c.getRoom().getId();
        JSONObject s = VideoSettings.getInitJson(sid);
        String _url = s.getString(VideoSettings.URL);
        Room room = roomDao.get(roomId);
        app = app.replace("$native", String.valueOf(s.getBoolean(FLASH_NATIVE_SSL))).replace("$codebase", WebSession.get().getExtendedProperties().getCodebase()).replace("$applicationName", getApplicationName()).replace("$url", _url).replace("$fallback", s.getString(VideoSettings.FALLBACK)).replace("$sid", sid).replace("$labels", getLabels("730", "731", "732", "733", "734", "735", "737", "738", "739", "740", "741", "742", "844", "869", "870", "871", "872", "878", "1089", "1090", "1091", "1092", "1093", "1465", "1466", "1467", "1468", "1469", "1470", "1471", "1472", "1473", "1474", "1475", "1476", "1477", "1589", "1598", "1078")).replace("$defaultQuality", String.valueOf(cfgDao.getLong(CONFIG_SCREENSHARING_QUALITY, 1L))).replace("$defaultFps", String.valueOf(cfgDao.getLong(CONFIG_SCREENSHARING_FPS, 10L))).replace("$showFps", String.valueOf(cfgDao.getBool(CONFIG_SCREENSHARING_FPS_SHOW, true))).replace("$allowRemote", String.valueOf(cfgDao.getBool(CONFIG_SCREENSHARING_ALLOW_REMOTE, true))).replace("$allowRecording", String.valueOf(room.isAllowRecording() && (0 == scm.getRecordingCount(roomId)))).replace("$allowPublishing", String.valueOf(0 == scm.getPublishingCount(roomId)));
        download.initiate(target);
    } catch (Exception e) {
        log.error("Unexpected error while creating jnlp file", e);
    }
}
Also used : JSONObject(com.github.openjson.JSONObject) InputStream(java.io.InputStream) Client(org.apache.openmeetings.db.entity.basic.Client) Room(org.apache.openmeetings.db.entity.room.Room)

Aggregations

JSONObject (com.github.openjson.JSONObject)64 JSONArray (com.github.openjson.JSONArray)23 Test (org.junit.jupiter.api.Test)11 AppointmentDTO (org.apache.openmeetings.db.dto.calendar.AppointmentDTO)7 Client (org.apache.openmeetings.db.entity.basic.Client)7 ArrayList (java.util.ArrayList)6 Whiteboard (org.apache.openmeetings.db.dto.room.Whiteboard)6 NullStringer (org.apache.openmeetings.util.NullStringer)6 Form (javax.ws.rs.core.Form)5 Response (javax.ws.rs.core.Response)5 List (java.util.List)4 Map (java.util.Map)4 OutputStreamWriter (java.io.OutputStreamWriter)3 Writer (java.io.Writer)3 MessageBodyWriter (javax.ws.rs.ext.MessageBodyWriter)3 Room (org.apache.openmeetings.db.entity.room.Room)3 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)3 JSONFunction (org.apache.wicket.ajax.json.JSONFunction)3 PageParameters (org.apache.wicket.request.mapper.parameter.PageParameters)3 JSONException (com.github.openjson.JSONException)2