Package org.jdesktop.wonderland.modules.presencemanager.common

Examples of org.jdesktop.wonderland.modules.presencemanager.common.PresenceInfo


      ArrayList<String> nameTagList = new ArrayList();

      PresenceInfo[] presenceInfoList = msg.getPresenceInfoList();

      for (int i = 0; i < presenceInfoList.length; i++) {
    PresenceInfo presenceInfo = presenceInfoList[i];

    logger.fine("Client connected: " + presenceInfo);

    logger.fine("Got ClientConnectResponse:  adding pi " + presenceInfo);
    pm.presenceInfoAdded(presenceInfo);

    String username = presenceInfo.getUserID().getUsername();

    if (presenceInfo.getCellID() == null) {
        logger.warning("CellID is null for " + presenceInfo);
        continue;
    }

    Cell cell = cellCache.getCell(presenceInfo.getCellID());

    if (cell == null) {
        logger.warning("Unable to find cell for " + presenceInfo.getCellID());
        continue;
    }

    NameTagComponent nameTag = cell.getComponent(NameTagComponent.class);

    if (presenceInfo.getUsernameAlias().equals(username) == false) {
         pm.changeUsernameAlias(presenceInfo, presenceInfo.getUsernameAlias());
     }

    if (nameTag == null) {
        continue;
    }

    nameTag.updateLabel(presenceInfo.getUsernameAlias(),
                                    presenceInfo.isInConeOfSilence(),
                                    presenceInfo.isSpeaking(),
                                    presenceInfo.isMuted());
      }

//      if (nameTagList.size() > 0) {
//    new NameTagUpdater(nameTagList);
//      }

            // connection is complete
            setConnectionComplete(true);

      return;
  }

        // Issue #1113: if the connection is not complete, ignore messages
        if (!isConnectionComplete()) {
            return;
        }

        if (message instanceof PlayerInRangeMessage) {
      PlayerInRangeMessage msg = (PlayerInRangeMessage) message;

      PresenceInfo info = pm.getPresenceInfo(msg.getCallID());

      if (info == null) {
    logger.fine("no presence info for callID " + msg.getCallID());
    return;
      }

      pm.playerInRange(info, msg.isInRange());
      return;
  }

        if (message instanceof PresenceInfoAddedMessage) {
            PresenceInfoAddedMessage m = (PresenceInfoAddedMessage) message;

            logger.fine("GOT PresenceInfoAddedMessage for " + m.getPresenceInfo());

            pm.presenceInfoAdded(m.getPresenceInfo());
            return;
        }

        if (message instanceof PresenceInfoRemovedMessage) {
            PresenceInfoRemovedMessage m = (PresenceInfoRemovedMessage) message;
            PresenceInfo pi = pm.getPresenceInfo(m.getCellID());
            if (pi == null) {
                logger.warning("No presence info found for " + m.getCellID());
                return;
            }

            logger.fine("GOT PresenceInfoRemovedMessage for " + pi);
            pm.presenceInfoRemoved(pi);
            return;
        }

        if (message instanceof PresenceInfoChangedMessage) {
            PresenceInfoChangedMessage m = (PresenceInfoChangedMessage) message;
            PresenceInfo pi = pm.getPresenceInfo(m.getCellID());
            if (pi == null) {
                logger.warning("No presence info found for " + m.getCellID());
                return;
            }

            logger.fine("GOT PresenceInfoChangeMessage for " + pi);
     
            switch (m.getChange()) {
                case SPEAKING:
                    pm.setSpeaking(pi, m.getValue());
                    break;
                case MUTED:
                    pm.setMute(pi, m.getValue());
                    break;
                case SECRET_CHAT:
                    pm.setInSecretChat(pi, m.getValue());
                    break;
                case CONE_OF_SILENCE:
                    pm.setEnteredConeOfSilence(pi, m.getValue());
                    break;
            }
            return;
        }

        if (message instanceof PresenceInfoChangedAliasMessage) {
            PresenceInfoChangedAliasMessage m = (PresenceInfoChangedAliasMessage) message;
            PresenceInfo pi = pm.getPresenceInfo(m.getCellID());
            if (pi == null) {
                logger.warning("No presence info found for " + m.getCellID());
                return;
            }
View Full Code Here


            wlID = AppContext.getManager(ClientIdentityManager.class).getClientID();
        }
       
        // first, generate a new PresenceInfo object for this client
        String callID = CallID.getCallID(cellID);
        PresenceInfo pi = new PresenceInfo(cellID, clientID, wlID, callID);

        // add the presence info object to our map
        getPresenceInfo().put(clientID, pi);

        // notify all clients of the new presence info
View Full Code Here

        listener.enableInRangeListener(wlClientID);
    }

    public void setUsernameAlias(BigInteger clientID, String alias) {
        PresenceInfo pi = getPresenceInfo(clientID);
        if (pi == null) {
            logger.warning("No presence info for " + clientID);
            return;
        }

        // set the alias
        pi.setUsernameAlias(alias);

        // send a message to the connection
        getPresenceSender().send(new PresenceInfoChangedAliasMessage(pi.getCellID(), alias));
    }
View Full Code Here

        // send a message to the connection
        getPresenceSender().send(new PresenceInfoChangedAliasMessage(pi.getCellID(), alias));
    }

    public void setInConeOfSilence(BigInteger clientID, boolean inCOS) {
        PresenceInfo pi = getPresenceInfo(clientID);
        if (pi == null) {
            logger.warning("No presence info for " + clientID);
            return;
        }

        // set the alias
        pi.setInConeOfSilence(inCOS);

        // send a message to the connection
        Message m = new PresenceInfoChangedMessage(pi.getCellID(),
                                                   Change.CONE_OF_SILENCE,
                                                   inCOS);
        getPresenceSender().send(m);
    }
View Full Code Here

    public void setSpeakingInGroup(WonderlandClientID targetID,
                                   BigInteger speakingID,
                                   boolean speaking)
    {
        PresenceInfo pi = getPresenceInfo(speakingID);
        if (pi == null) {
            logger.warning("No presence info for " + speakingID);
            return;
        }

        Message m = new PresenceInfoChangedMessage(pi.getCellID(),
                                                   Change.SPEAKING, speaking);
        getPresenceSender().send(m);
    }
View Full Code Here

            listener.done();
            AppContext.getDataManager().removeObject(listener);
        }

        // remove the presence info for this user
        PresenceInfo pi = getPresenceInfo().remove(clientID);

        // notify listeners
        if (pi == null) {
            logger.warning("[PresenceManagerConnectionHandler] No presence " +
                           "info found for " + clientID);
        } else {
            getPresenceSender().send(new PresenceInfoRemovedMessage(pi.getCellID()));
        }

        return pi;
    }
View Full Code Here

      if (player == null) {
          logger.warning("[PlayerListener] No player for " + callID);
                return;
            }

            PresenceInfo pi = presenceMapRef.get().get(clientID);
            if (pi == null) {
                logger.warning("[PlayerListener] No presence info for " + clientID);
                return;
            }

            switch (status.getCode()) {
                case CallStatus.ESTABLISHED:
                    if (inRangeListener != null) {
                        player.addPlayerInRangeListener(inRangeListener);
                    }
                    break;

                case CallStatus.MUTED:
                    pi.setMuted(true);
                    sender.send(new PresenceInfoChangedMessage(cellID, Change.MUTED, true));
                    break;

                case CallStatus.UNMUTED:
                    pi.setMuted(false);
                    sender.send(new PresenceInfoChangedMessage(cellID, Change.MUTED, false));
                    break;

                case CallStatus.STARTEDSPEAKING:
                    // ignore this indicator if the player is in a secret
View Full Code Here

            callIDMap.put(presenceInfo.getCallID(), presenceInfo);
        }
    }

    private boolean alreadyInMaps(PresenceInfo presenceInfo) {
        PresenceInfo info;

        if (presenceInfo.getCellID() != null) {
            info = cellIDMap.get(presenceInfo.getCellID());

            if (info != null && info.equals(presenceInfo) == false) {
                logger.info("Already in cellIDMap:  Existing PI " + info + " new PI " + presenceInfo);
                return true;
            }
        }

        if (presenceInfo.getClientID() != null) {
            info = sessionIDMap.get(presenceInfo.getClientID());

            if (info != null && info.equals(presenceInfo) == false) {
                logger.info("Already in clientIDMap:  Existing PI " + info + " new PI " + presenceInfo);
                return true;
            }
        }

        if (presenceInfo.getUserID() != null) {
            info = userIDMap.get(presenceInfo.getUserID());

            if (info != null && info.equals(presenceInfo) == false) {
                logger.info("Already in userIDMap:  Existing PI " + info + " new PI " + presenceInfo);
                return true;
            }
        }

        if (presenceInfo.getCallID() != null) {
            info = callIDMap.get(presenceInfo.getCallID());

            if (info != null && info.equals(presenceInfo) == false) {
                logger.info("Already in callIDMap:  Existing PI " + info + " new PI " + presenceInfo);
                return true;
            }
        }
View Full Code Here

     * @param CellID the CellID of the ViewCell
     * @return PresenceInfo the PresenceInfo assoicated with the CellID.
     */
    public PresenceInfo getPresenceInfo(CellID cellID) {
        synchronized (cellIDMap) {
            PresenceInfo info = cellIDMap.get(cellID);

            if (info == null) {
                logger.fine("No presence info for CellID " + cellID);
                return null;
            }
View Full Code Here

        if (sessionID == null) {
            return null;
        }

        synchronized (sessionIDMap) {
            PresenceInfo info = sessionIDMap.get(sessionID);

            if (info == null) {
                logger.fine("No presence info for sessionID " + sessionID);
                return null;
            }
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.modules.presencemanager.common.PresenceInfo

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.