Package org.red5.server.api

Examples of org.red5.server.api.IConnection


    // Notify all the clients that the stream had been closed
    log.debug("start streamBroadcastClose broadcast close: "
        + stream.getPublishedName());
    try {
      IConnection current = Red5.getConnectionLocal();
      Client rcl = sessionManager.getClientByStreamId(current.getClient().getId(), null);
      sendClientBroadcastNotifications(stream, "closeStream", rcl);
    } catch (Exception e) {
      log.error("[streamBroadcastClose]", e);
    }
  }
View Full Code Here


   *
   */
  private synchronized void sendClientBroadcastNotifications(IBroadcastStream stream, String clientFunction, Client rc) {
    try {
      // Store the local so that we do not send notification to ourself back
      IConnection current = Red5.getConnectionLocal();
      String streamid = current.getClient().getId();
      Client currentClient = sessionManager.getClientByStreamId(streamid, null);

      if (currentClient == null) {

        // In case the client has already left(kicked) this message
        // might be thrown later then the RoomLeave
        // event and the currentClient is already gone
        // The second Use-Case where the currentClient is maybe null is
        // if we remove the client because its a Zombie/Ghost

        return;

      }
      // Notify all the clients that the stream had been started
      log.debug("sendClientBroadcastNotifications: " + stream.getPublishedName());
      log.debug("sendClientBroadcastNotifications : " + currentClient + " " + currentClient.getStreamid());

      // Notify all clients of the same scope (room)
      for (Set<IConnection> conset : current.getScope().getConnections()) {
      for (IConnection conn : conset) {
        if (conn != null) {
          if (conn instanceof IServiceCapableConnection) {
            if (conn.equals(current)) {
              // there is a Bug in the current implementation
              // of the appDisconnect
              if (clientFunction.equals("closeStream")) {
                Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null);
                if (clientFunction.equals("closeStream") && rcl.getIsRecording()) {
                  log.debug("*** stopRecordingShowForClient Any Client is Recording - stop that");
                  // StreamService.stopRecordingShowForClient(conn,
                  // currentClient,
                  // rcl.getRoomRecordingName(), false);
                  flvRecorderService.stopRecordingShowForClient(conn, currentClient);
                }
                // Don't notify current client
                current.ping();
              }
              continue;
            } else {
              Client rcl = sessionManager.getClientByStreamId(conn.getClient().getId(), null);
              if (rcl != null) {
View Full Code Here

  @SuppressWarnings("unchecked")
  public void setNewCursorPosition(Object item) {
    try {

      IConnection current = Red5.getConnectionLocal();
      String streamid = current.getClient().getId();
      Client currentClient = this.sessionManager
          .getClientByStreamId(streamid, null);

      @SuppressWarnings("rawtypes")
      Map cursor = (Map) item;
      cursor.put("streamPublishName",
          currentClient.getStreamPublishName());

      // Notify all users of the same Scope
      for (Set<IConnection> conset : current.getScope().getConnections()) {
      for (IConnection conn : conset) {
        if (conn != null) {
          if (conn instanceof IServiceCapableConnection) {
            IClient client = conn.getClient();
            if (SessionVariablesUtil.isScreenClient(client)) {
              // screen sharing clients do not receive events
              continue;
            } else if (SessionVariablesUtil.isAVClient(client)) {
              // AVClients or potential AVClients do not receive events
              continue;
            } if (client.getId().equals(
                  current.getClient().getId())) {
              // don't send back to same user
              continue;
            }
            ((IServiceCapableConnection) conn).invoke("newRed5ScreenCursor", new Object[] { cursor }, this);
          }
View Full Code Here

  public synchronized Long removeModerator(String publicSID) {
    try {
      log.debug("-----------  removeModerator: " + publicSID);

      IConnection current = Red5.getConnectionLocal();
      // String streamid = current.getClient().getId();

      Client currentClient = this.sessionManager
          .getClientByPublicSID(publicSID, false, null);

      if (currentClient == null) {
        return -1L;
      }
      Long room_id = currentClient.getRoom_id();

      currentClient.setIsMod(false);
      // Put the mod-flag to true for this client
      this.sessionManager.updateClientByStreamId(
          currentClient.getStreamid(), currentClient, false, null);

      List<Client> currentMods = this.sessionManager
          .getCurrentModeratorByRoom(room_id);

      // Notify all clients of the same scope (room)
      for (Set<IConnection> conset : current.getScope().getConnections()) {
      for (IConnection conn : conset) {
        if (conn != null) {
          if (conn instanceof IServiceCapableConnection) {
            IClient client = conn.getClient();
            if (SessionVariablesUtil.isScreenClient(client)) {
View Full Code Here

  public synchronized Long setBroadCastingFlag(String publicSID,
      boolean value, Integer interviewPodId) {
    try {
      log.debug("-----------  setBroadCastingFlag: " + publicSID);

      IConnection current = Red5.getConnectionLocal();
      // String streamid = current.getClient().getId();

            Client currentClient = sessionManager.getClientByPublicSID(publicSID, false, null);

      if (currentClient == null) {
        return -1L;
      }

      currentClient.setIsBroadcasting(value);
      currentClient.setInterviewPodId(interviewPodId);

            // Put the mod-flag to true for this client
        sessionManager.updateClientByStreamId(currentClient.getStreamid(), currentClient, false, null);
       
      // Notify all clients of the same scope (room)
      for (Set<IConnection> conset : current.getScope().getConnections()) {
      for (IConnection conn : conset) {
        if (conn != null) {
          if (conn instanceof IServiceCapableConnection) {
            IClient client = conn.getClient();
            if (SessionVariablesUtil.isScreenClient(client)) {
View Full Code Here

  public synchronized Long giveExclusiveAudio(String publicSID) {
    try {
      log.debug("-----------  giveExclusiveAudio: " + publicSID);

      IConnection current = Red5.getConnectionLocal();
      // String streamid = current.getClient().getId();

      Client currentClient = this.sessionManager
          .getClientByPublicSID(publicSID, false, null);

      if (currentClient == null) {
        return -1L;
      }

      // Put the mod-flag to true for this client
      currentClient.setMicMuted(false);
      this.sessionManager.updateClientByStreamId(
          currentClient.getStreamid(), currentClient, false, null);

      // Notify all clients of the same scope (room)
      for (Set<IConnection> conset : current.getScope().getConnections()) {
      for (IConnection conn : conset) {
        if (conn != null) {
          Client rcl = this.sessionManager
              .getClientByStreamId(conn.getClient().getId(), null);
          if (rcl == null) {
View Full Code Here

   * @return long broadCastId
   */
  public synchronized long getBroadCastId() {
    try {
      log.debug("-----------  getBroadCastId");
      IConnection current = Red5.getConnectionLocal();
      String streamid = current.getClient().getId();
      Client currentClient = this.sessionManager
          .getClientByStreamId(streamid, null);
      currentClient.setBroadCastID(broadCastCounter++);
      this.sessionManager.updateClientByStreamId(streamid,
          currentClient, false, null);
View Full Code Here

   */
  public synchronized Client setUserAVSettings(String avsettings,
      Object newMessage, Integer vWidth, Integer vHeight,
      long room_id, String publicSID, Integer interviewPodId) {
    try {
      IConnection current = Red5.getConnectionLocal();
      IClient c = current.getClient();
      String streamid = c.getId();
      log.debug("-----------  setUserAVSettings {} {} {}", new Object[] {streamid, publicSID, avsettings, newMessage});
      Client parentClient = sessionManager.getClientByPublicSID(publicSID, false, null);
      Client currentClient = sessionManager.getClientByStreamId(streamid, null);
      currentClient.setAvsettings(avsettings);
      currentClient.setRoom_id(room_id);
      currentClient.setPublicSID(publicSID);
      currentClient.setVWidth(vWidth);
      currentClient.setVHeight(vHeight);
      currentClient.setInterviewPodId(interviewPodId);
      currentClient.setUser_id(parentClient.getUser_id());
      currentClient.setLastname(parentClient.getLastname());
      currentClient.setFirstname(parentClient.getFirstname());
      currentClient.setPicture_uri(parentClient.getPicture_uri());
      sessionManager.updateAVClientByStreamId(streamid, currentClient, null);
      SessionVariablesUtil.initClient(c, false, publicSID);

      HashMap<String, Object> hsm = new HashMap<String, Object>();
      hsm.put("client", currentClient);
      hsm.put("message", newMessage);

      for (Set<IConnection> conset : current.getScope().getConnections()) {
      for (IConnection conn : conset) {
        if (conn != null) {
          if (conn instanceof IServiceCapableConnection) {
            IClient client = conn.getClient();
            if (SessionVariablesUtil.isScreenClient(client)) {
View Full Code Here

    try {
      log.debug("-----------  setRoomValues");
      // Return Object
      RoomStatus roomStatus = new RoomStatus();

      IConnection current = Red5.getConnectionLocal();
      String streamid = current.getClient().getId();
      Client currentClient = sessionManager.getClientByStreamId(streamid, null);
      currentClient.setRoom_id(room_id);
      currentClient.setRoomEnter(new Date());
      currentClient.setOrganization_id(organization_id);

      currentClient.setUsercolor(colorObj);

      // Inject externalUserId if nothing is set yet
      if (currentClient.getExternalUserId() == null) {
        if (currentClient.getUser_id() != null) {
          User us = usersDao.get(currentClient.getUser_id());
          if (us != null) {
            currentClient.setExternalUserId(us.getExternalUserId());
            currentClient.setExternalUserType(us.getExternalUserType());
          }
        }
      }

      // This can be set without checking for Moderation Flag
      currentClient.setIsSuperModerator(isSuperModerator);

      this.sessionManager.updateClientByStreamId(streamid,
          currentClient, true, null);

            Room room = roomDao.get(room_id);
            if (room.getShowMicrophoneStatus()) {
              currentClient.setCanGiveAudio(true);
            }

      // Log the User
      conferenceLogDao.addConferenceLog("roomEnter",
          currentClient.getUser_id(), streamid, room_id,
          currentClient.getUserip(), "",
          currentClient.getExternalUserId(),
          currentClient.getExternalUserType(),
          currentClient.getMail(), currentClient.getFirstname(),
          currentClient.getLastname());
     
      // Check for Moderation LogicalRoom ENTER
      List<Client> clientListRoom = sessionManager.getClientListByRoom(room_id);

      // appointed meeting or moderated Room? => Check Max Users first
      if (room.getNumberOfPartizipants() != null
          && clientListRoom.size() > room.getNumberOfPartizipants()) {
        roomStatus.setRoomFull(true);
        return roomStatus;
      }

      // default logic for non regular rooms
      if (room.getAppointment() == null || room.getAppointment() == false) {

        if (room.getIsModeratedRoom()) {

          // if this is a Moderated Room then the Room can be only
          // locked off by the Moderator Bit
          // List<RoomClient> clientModeratorListRoom =
          // this.sessionManager.getCurrentModeratorByRoom(room_id);

          // If there is no Moderator yet we have to check if the
          // current User has the Bit set to true to
          // become one, otherwise he won't get Moderation and has to
          // wait
          if (becomeModerator) {
            currentClient.setIsMod(true);

            // There is a need to send an extra Event here, cause at
            // this moment there could be
            // already somebody in the Room waiting

            // Update the Client List
            this.sessionManager.updateClientByStreamId(streamid,
                currentClient, false, null);

            List<Client> modRoomList = this.sessionManager
                .getCurrentModeratorByRoom(currentClient.getRoom_id());
           
            //Sync message to everybody
            syncMessageToCurrentScope("setNewModeratorByList", modRoomList, false);

          } else {
            // The current User is not a Teacher/Admin or whatever
            // Role that should get the
            // Moderation
            currentClient.setIsMod(false);
          }

        } else {

          // If this is a normal Room Moderator rules : first come,
          // first draw ;-)
          log.debug("setRoomValues : Room"
              + room_id
              + " not appointed! Moderator rules : first come, first draw ;-)");
          if (clientListRoom.size() == 1) {
            log.debug("Room is empty so set this user to be moderation role");
            currentClient.setIsMod(true);
          } else {
            log.debug("Room is already somebody so set this user not to be moderation role");

            if (becomeModerator) {
              currentClient.setIsMod(true);

              // Update the Client List
              this.sessionManager.updateClientByStreamId(
                  streamid, currentClient, false, null);

              List<Client> modRoomList = this.sessionManager
                  .getCurrentModeratorByRoom(currentClient
                      .getRoom_id());

              // There is a need to send an extra Event here,
              // cause at this moment there could be
              // already somebody in the Room waiting -swagner check this comment, 20.01.2012
             
              //Sync message to everybody
              syncMessageToCurrentScope("setNewModeratorByList", modRoomList, false);

            } else {
              // The current User is not a Teacher/Admin or
              // whatever Role that should get the Moderation
              currentClient.setIsMod(false);
            }

          }

        }

        // Update the Client List
        this.sessionManager.updateClientByStreamId(streamid,
            currentClient, false, null);

      } else {

        // If this is an Appointment then the Moderator will be set to
        // the Invitor

        Appointment ment = appointmentLogic.getAppointmentByRoom(room_id);

        Long userIdInRoomClient = currentClient.getUser_id();

        boolean found = false;
        boolean moderator_set = false;

        // Check if current user is set to moderator
        for (MeetingMember member : ment.getMeetingMembers()) {

          // only persistent users can schedule a meeting
          // user-id is only set for registered users
          if (member.getUser() != null) {
            log.debug("checking user " + member.getUser().getFirstname()
                + " for moderator role - ID : "
                + member.getUser().getUser_id());

            if (member.getUser().getUser_id().equals(userIdInRoomClient)) {
              found = true;

              if (ment.getOwner().getUser_id() == member.getUser().getUser_id()) {
                log.debug("User "
                    + userIdInRoomClient
                    + " is moderator due to flag in MeetingMember record");
                currentClient.setIsMod(true);

                // Update the Client List
                sessionManager.updateClientByStreamId(streamid, currentClient, false, null);

                List<Client> modRoomList = this.sessionManager
                    .getCurrentModeratorByRoom(currentClient
                        .getRoom_id());

                // There is a need to send an extra Event here, cause at this moment
                // there could be already somebody in the Room waiting

                //Sync message to everybody
                syncMessageToCurrentScope("setNewModeratorByList", modRoomList, false);

                moderator_set = true;
                this.sessionManager.updateClientByStreamId(
                    streamid, currentClient, false, null);
                break;
              } else {
                log.debug("User "
                    + userIdInRoomClient
                    + " is NOT moderator due to flag in MeetingMember record");
                currentClient.setIsMod(false);
                this.sessionManager.updateClientByStreamId(
                    streamid, currentClient, false, null);
                break;
              }
            }
          }

        }

        if (!found) {
          log.debug("User "
              + userIdInRoomClient
              + " could not be found as MeetingMember -> definitely no moderator");
          currentClient.setIsMod(false);
          sessionManager.updateClientByStreamId(streamid, currentClient, false, null);
        } else {
          // if current user is part of the member list, but moderator
          // couldn't be retrieved : first come, first draw!
          if (clientListRoom.size() == 1 && moderator_set == false) {
            log.debug("");
            currentClient.setIsMod(true);

            // Update the Client List
            sessionManager.updateClientByStreamId(streamid, currentClient, false, null);

            List<Client> modRoomList = this.sessionManager
                .getCurrentModeratorByRoom(currentClient
                    .getRoom_id());

            // There is a need to send an extra Event here, cause at
            // this moment there could be
            // already somebody in the Room waiting

            //Sync message to everybody
            syncMessageToCurrentScope("setNewModeratorByList", modRoomList, false);
           
            this.sessionManager.updateClientByStreamId(streamid,
                currentClient, false, null);
          }
        }

      }
     
      //Sync message to everybody
      syncMessageToCurrentScope("addNewUser", currentClient, false);

      //Status object for Shared Browsing
      BrowserStatus browserStatus = (BrowserStatus) current.getScope()
          .getAttribute("browserStatus");

      if (browserStatus == null) {
        browserStatus = new BrowserStatus();
      }
View Full Code Here

  public synchronized Client setUsernameReconnect(String SID,
      Long userId, String username, String firstname, String lastname,
      String picture_uri) {
    try {
      log.debug("-----------  setUsernameReconnect");
      IConnection current = Red5.getConnectionLocal();
      String streamid = current.getClient().getId();
      Client currentClient = this.sessionManager
          .getClientByStreamId(streamid, null);

      currentClient.setUsername(username);
      currentClient.setUser_id(userId);
      SessionVariablesUtil.setUserId(current.getClient(), userId);
      currentClient.setPicture_uri(picture_uri);
      currentClient.setUserObject(userId, username, firstname, lastname);

      // Update Session Data
      sessiondataDao.updateUserWithoutSession(SID, userId);
View Full Code Here

TOP

Related Classes of org.red5.server.api.IConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.