Search in sources :

Example 6 with RoomMessage

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

the class StreamClientManager method update.

@Override
public StreamClient update(StreamClient rcl, boolean forceSize) {
    if (rcl == null) {
        return null;
    }
    Client client = clientManager.getBySid(rcl.getSid());
    if (client == null) {
        if (Client.Type.mobile == rcl.getType()) {
            Sessiondata sd = sessionDao.check(rcl.getSid());
            User u = userDao.get(sd.getUserId());
            rcl = mobileService.create(rcl, u);
            // Mobile client enters the room
            client = new Client(rcl, userDao.get(rcl.getUserId()));
            clientManager.add(client);
            if (rcl.getRoomId() != null) {
                client.setCam(0);
                client.setMic(0);
                client.setRoom(roomDao.get(rcl.getRoomId()));
                clientManager.add(client);
                WebSocketHelper.sendRoom(new RoomMessage(client.getRoom().getId(), client, RoomMessage.Type.roomEnter));
            }
        } else if (client == null && Client.Type.sip == rcl.getType()) {
            rcl.setLogin(SIP_USER_NAME);
            rcl.setUserId(SIP_USER_ID);
            // SipTransport enters the room
            User u = new User();
            u.setId(SIP_USER_ID);
            u.setLogin(SIP_USER_NAME);
            u.setFirstname(SIP_FIRST_NAME);
            client = new Client(rcl, u);
            clientManager.add(client);
            client.setCam(0);
            client.setMic(0);
            client.allow(Room.Right.audio, Room.Right.video);
            client.set(Activity.broadcastA);
            clientManager.addToRoom(client);
            WebSocketHelper.sendRoom(new RoomMessage(client.getRoom().getId(), client, RoomMessage.Type.roomEnter));
        } else {
            return null;
        }
    }
    if (rcl.getRoomId() == null || !rcl.getRoomId().equals(client.getRoom().getId())) {
        return null;
    }
    User u = client.getUser();
    rcl.setUserId(u.getId());
    rcl.setLogin(u.getLogin());
    rcl.setFirstname(u.getFirstname());
    rcl.setLastname(u.getLastname());
    rcl.setEmail(u.getAddress() == null ? null : u.getAddress().getEmail());
    rcl.setSuperMod(client.hasRight(Right.superModerator));
    rcl.setMod(client.hasRight(Right.moderator));
    if (client.hasActivity(Activity.broadcastA) && !client.isMicEnabled()) {
        client.remove(Activity.broadcastA);
    }
    if (client.hasActivity(Activity.broadcastV) && !client.isCamEnabled()) {
        client.remove(Activity.broadcastV);
    }
    if (client.hasActivity(Activity.broadcastA) || client.hasActivity(Activity.broadcastV)) {
        if (forceSize || rcl.getWidth() == 0 || rcl.getHeight() == 0) {
            rcl.setWidth(client.getWidth());
            rcl.setHeight(client.getHeight());
        }
        if (client.getPod() != Pod.none) {
            rcl.setInterviewPodId(client.getPod() == Pod.left ? 1 : 2);
        }
        StringBuilder sb = new StringBuilder();
        if (client.hasActivity(Activity.broadcastA)) {
            sb.append('a');
        }
        if (client.hasActivity(Activity.broadcastV)) {
            sb.append('v');
        }
        if (!rcl.isBroadcasting() || hasVideo(rcl) != hasVideo(client)) {
            rcl.setBroadcasting(true);
        }
        rcl.setAvsettings(sb.toString());
    } else {
        rcl.setAvsettings("n");
        rcl.setBroadcasting(false);
    }
    clientManager.update(client);
    streamClientManager.update(rcl);
    return rcl;
}
Also used : User(org.apache.openmeetings.db.entity.user.User) RoomMessage(org.apache.openmeetings.db.util.ws.RoomMessage) Sessiondata(org.apache.openmeetings.db.entity.server.Sessiondata) IClient(org.apache.openmeetings.db.entity.basic.IClient) StreamClient(org.apache.openmeetings.db.entity.room.StreamClient) Client(org.apache.openmeetings.db.entity.basic.Client)

Example 7 with RoomMessage

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

the class RoomWebService method close.

/**
 * Method to remotely close rooms. If a room is closed all users
 * inside the room and all users that try to enter it will be redirected to
 * the redirectURL that is defined in the Room-Object.
 *
 * Returns positive value if authentication was successful.
 *
 * @param sid
 *            The SID of the User. This SID must be marked as Loggedin
 * @param id
 *            the room id
 *
 * @return - 1 in case of success, -2 otherwise
 */
@WebMethod
@GET
@Path("/close/{id}")
public ServiceResult close(@WebParam(name = "sid") @QueryParam("sid") String sid, @WebParam(name = "id") @PathParam("id") long id) {
    return performCall(sid, User.Right.Soap, sd -> {
        Long userId = sd.getUserId();
        Room room = roomDao.get(id);
        room.setClosed(true);
        roomDao.update(room, userId);
        WebSocketHelper.sendRoom(new RoomMessage(room.getId(), userDao.get(userId), RoomMessage.Type.roomClosed));
        return new ServiceResult("Closed", Type.SUCCESS);
    });
}
Also used : ServiceResult(org.apache.openmeetings.db.dto.basic.ServiceResult) RoomMessage(org.apache.openmeetings.db.util.ws.RoomMessage) Room(org.apache.openmeetings.db.entity.room.Room) WebMethod(javax.jws.WebMethod) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

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