org.sakaiproject.tool.api.Session.getId()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中org.sakaiproject.tool.api.Session.getId()方法的一些代码示例,展示了Session.getId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Session.getId()方法的具体详情如下:
包路径:org.sakaiproject.tool.api.Session
类名称:Session
方法名:getId

Session.getId介绍

[英]Returns a string containing the unique identifier assigned to this session.
[中]返回一个字符串,其中包含分配给该会话的唯一标识符。

代码示例

代码示例来源:origin: stackoverflow.com

@Override
public void delete(Session session) {
  // repository.delete(session);
  if (session.getId() > 0) {

    query = em.createNativeQuery("DELETE FROM `t_session` WHERE `id` = :t_session", Session.class);
    query.setParameter("t_session", session.getId());
    query.executeUpdate();
  }
}`

代码示例来源:origin: stackoverflow.com

@OnOpen
public void onOpen(Session session) {
  logger.info("Client with session id:"+session.getId()+" connected.");

  //use either session.getAsyncRemote() or session.getBasicRemote()

}

代码示例来源:origin: stackoverflow.com

@OnClose
public void onConnectionClose(Session session) {
  openSessions.remove(session.getId());
}

代码示例来源:origin: stackoverflow.com

Map<String, Session> map = new HashMap<>();
static Map<String, Session> peers = Collections.synchronizedMap(map);

@OnOpen
public void onOpen(Session session) {
  peers.add(session.getId(), session);
}

@OnClose
public void onClose(Session session) {
  peers.remove(session.getId());
}

private static Session findOtherSessionById(Session user, String id) {
  if (peers.containsKey(user.getId()) {
    return peers.get(user.getId());
  }
}

代码示例来源:origin: org.sakaiproject/sakai-citations-impl

protected String newSearchId()
{
  /******* A unique ID per-session ********/
  return m_sessionManager.getCurrentSession().getId();
  /******* Unique ID per-search (original)
  String sessionId = m_sessionManager.getCurrentSession().getId();
  long number = m_generator.nextLong();
  String hexString = Long.toHexString(number);
  m_log.debug("getSearchId:  " + sessionId + hexString);
  return sessionId + hexString;
   *************************************************************************/
}

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

/**
 * {@inheritDoc}
 */
public boolean equals(Object obj)
{
  if (!(obj instanceof Session))
  {
    return false;
  }
  return ((Session) obj).getId().equals(getId());
}

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

@ManagedAttribute(description="Sessions IDs (will match the cookie value)", currencyTimeLimit=0)
public List<String> getSessionsIds() {
  List<Session> sessions = sessionManager.getSessions();
  List<String> ids = new ArrayList<String>(sessions.size());
  for (Session session : sessions) {
    ids.add(session.getId());
  }
  return ids;
}

代码示例来源:origin: stackoverflow.com

@OnMessage
 public void message(Session session, String msg){
   try {
     JSONObject obj = new JSONObject(msg);
     if (!obj.has("toUserId")){
       //adding user to the database, so they can access their session ID with their user ID
       WebsocketUser wsu = new WebsocketUser(obj.getLong("userId"), session.getId());
       tx.begin();
       em.persist(wsu);
       tx.commit();
     }else if (obj.has("toUserId")){
       //message to be sent to the user with the specified user ID
       //get session ID from database
       query = em.createQuery("SELECT u FROM WebsocketUser u WHERE u.userId = " + obj.getLong("toUserId"), WebsocketUser.class);
       wsu = (WebsocketUser) query.getSingleResult();
       Set<Session> sessions = session.getOpenSessions();
       for (Iterator<Session> i = sessions.iterator(); i.hasNext();){
         Session s = i.next();
         if (s.getId().equals(wsu.getSessionId())){
           s.getAsyncRemote().sendText(obj.getString("message"));
           break;
         }
       }
     }
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }

代码示例来源:origin: sakaiproject/sakai

/**
 * Construct.
 * 
 * @param location
 *        The key identifying the client window to which this courier delivers updates.
 * @param elementId
 *        The key identifying the element on the Portal Page that would need a courier delivered message when things change.
 */
public ObservingCourier(String location, String elementId)
{
  m_deliveryId = SessionManager.getCurrentSession().getId() + location;
  m_elementId = elementId;
  m_location = location;
  // "inject" a CourierService
  m_courierService = org.sakaiproject.courier.cover.CourierService.getInstance();
}

代码示例来源:origin: stackoverflow.com

for (Session s : sessions) {
  if (nameSessionPair.get(this.to).equals(s.getId())) {
    System.out.print("True");
    Campusian c = new Campusian();

代码示例来源:origin: uk.org.ponder.sakairsf/sakairsf

public String getId() {
 ToolSession toolSession = sessionmanager.getCurrentToolSession();
 return toolSession == null ? sessionmanager.getCurrentSession().getId()
   : toolSession.getId();
}

代码示例来源:origin: org.sakaiproject.presence/sakai-presence-impl

/**
 * Check all session presences and remove any expired ones
 */
@SuppressWarnings("unchecked")
protected void checkAllPresenceForExpiration()
{
  List<Session> sessions = m_sessionManager.getSessions();
  
  for (Iterator<Session> i = sessions.iterator(); i.hasNext();)
  {
    Session session = (Session) i.next();
    ToolSession ts = session.getToolSession(SESSION_KEY);
    Enumeration locations = ts.getAttributeNames();
    while (locations.hasMoreElements())
    {
      String location = (String) locations.nextElement();
      Presence p = (Presence) ts.getAttribute(location);
      if (M_log.isDebugEnabled()) M_log.debug("checking expiry of session " + session.getId() + " in location " + location);
      
      if (p != null && p.isExpired())
      {
        ts.removeAttribute(location);
      }
    }
  
  }
}

代码示例来源:origin: sakaiproject/sakai

public String getId() {
  ToolSession toolSession = sessionmanager.getCurrentToolSession();
  return toolSession == null ? sessionmanager.getCurrentSession().getId() : toolSession.getId();
}

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

throw new IllegalArgumentException("session ("+s.getId()+") MUST be a MySession implementation");
if (log.isDebugEnabled()) log.debug("Session ("+s.getId()+") not valid for clustering, not a MySession");
return false;

代码示例来源:origin: sakaiproject/sakai

/**
 * Compute the deliver address for the current request. Compute the client window id, based on the float state
 * 
 * @param state
 *        The tool state.
 * @param toolId
 *        The tool instance id, which might be used as part of the client window id if floating.
 * @return The client window id, based on the float state.
 */
protected String clientWindowId(SessionState state, String toolId)
{
  // TODO: drop the params
  // get the Sakai session
  Session session = SessionManager.getCurrentSession();
  // get the current tool placement
  Placement placement = ToolManager.getCurrentPlacement();
  // compute our courier delivery address: this placement in this session
  String deliveryId = session.getId() + placement.getId();
  return deliveryId;
} // clientWindowId

代码示例来源:origin: sakaiproject/sakai

String sessionId = getSessionManager().getCurrentSession().getId();

代码示例来源:origin: org.sakaiproject.kernel/sakai-kernel-impl

/**
 * @inheritDoc
 */
public Session startSession(String id)
{
  if (isClosing()) {
    throw new ClosingException();
  }
  // create a non portable session object if this is a clustered environment
  NonPortableSession nPS = new MyNonPortableSession();
  // create a new MutableLong object representing the current time that both
  // the Session and SessionManager can see.
  MutableLong currentTime = currentTimeMutableLong();
  // create a new session
  Session s = new MySession(this,id,threadLocalManager(),idManager(),this,sessionListener,m_defaultInactiveInterval,nPS,currentTime,rebuildBreakdownService());
  // Place session into the main Session Storage, capture any old id
  Session old = m_sessions.put(s.getId(), s);
  // Place an entry in the expirationTimeSuggestionMap that corresponds to the entry in m_sessions
  expirationTimeSuggestionMap.put(id, currentTime);
  // check for id conflict
  if (old != null)
  {
    log.warn("startSession: duplication id: " + s.getId());
  }
  return s;
}

代码示例来源:origin: org.sakaiproject.velocity/sakai-velocity-tool

/**
 * Compute the deliver address for the current request. Compute the client window id, based on the float state
 * 
 * @param state
 *        The tool state.
 * @param toolId
 *        The tool instance id, which might be used as part of the client window id if floating.
 * @return The client window id, based on the float state.
 */
protected String clientWindowId(SessionState state, String toolId)
{
  // TODO: drop the params
  // get the Sakai session
  Session session = SessionManager.getCurrentSession();
  // get the current tool placement
  Placement placement = ToolManager.getCurrentPlacement();
  // compute our courier delivery address: this placement in this session
  String deliveryId = session.getId() + placement.getId();
  return deliveryId;
} // clientWindowId

代码示例来源:origin: sakaiproject/sakai

String sessionId = getSessionManager().getCurrentSession().getId();
log.debug("Retrieving locale for sessionId: " + sessionId);
loc = (Locale) getSessionManager().getCurrentSession().getAttribute(LOCALE_SESSION_KEY+sessionId);

代码示例来源:origin: org.sakaiproject/sakai-chat-impl

String sessionId = session.getId();

相关文章