Package org.directwebremoting

Examples of org.directwebremoting.ScriptSession


     * @param request
     * @return
     */ 
    @SuppressWarnings("unchecked"
    public ScriptSession getScriptSession(String userid, HttpServletRequest request) { 
        ScriptSession scriptSessions = null
        Collection<ScriptSession> sessions = new HashSet<ScriptSession>()
       // sessions.addAll(ServerContextFactory.get(request.getSession().getServletContext()) 
         //       .getScriptSessionsByPage("/ind.jsp")); 
        sessions.addAll(ServerContextFactory.get(request.getSession().getServletContext()) 
                .getScriptSessionsByPage("/fly-web/ind.jsp"));
View Full Code Here


     * @param receiverid ������id
     * @param msg ��Ϣ����
     * @param request
     */ 
    public void send(String sender,String receiverid,String msg,HttpServletRequest request){ 
        ScriptSession session = this.getScriptSession(receiverid, request)
        //
        ScriptSession scriptSessions = null
        Collection<ScriptSession> sessions = new HashSet<ScriptSession>();
        sessions.addAll(ServerContextFactory.get(request.getSession().getServletContext()) 
                .getScriptSessionsByPage("/fly-web/ind.jsp"))
        for (ScriptSession session1 : sessions) {         
            ScriptBuffer sb = new ScriptBuffer();
View Full Code Here

     * @param request
     * @return
     */ 
    @SuppressWarnings("unchecked"
    public ScriptSession getScriptSession(String userid, HttpServletRequest request) { 
        ScriptSession scriptSessions = null
        Collection<ScriptSession> sessions = new HashSet<ScriptSession>()
       // sessions.addAll(ServerContextFactory.get(request.getSession().getServletContext()) 
         //       .getScriptSessionsByPage("/ind.jsp")); 
        sessions.addAll(ServerContextFactory.get(request.getSession().getServletContext()) 
                .getScriptSessionsByPage("/fly-web/ind.jsp"));
View Full Code Here

     * @param receiverid ������id
     * @param msg ��Ϣ����
     * @param request
     */ 
    public void send(String sender,String receiverid,String msg,HttpServletRequest request){ 
        ScriptSession session = this.getScriptSession(receiverid, request)
        //
        ScriptSession scriptSessions = null
        Collection<ScriptSession> sessions = new HashSet<ScriptSession>();
        sessions.addAll(ServerContextFactory.get(request.getSession().getServletContext()) 
                .getScriptSessionsByPage("/fly-web/ind.jsp"))
        for (ScriptSession session1 : sessions) {         
            ScriptBuffer sb = new ScriptBuffer();
View Full Code Here

  public static final String SESSION_USER = "23654895";
   public static final String SS_ID = "DWR_ScriptSession_Id"
     public CustomSSManager() { 
          addScriptSessionListener(new ScriptSessionListener(){ 
             public void sessionCreated(ScriptSessionEvent event) { 
                     ScriptSession scriptSession = event.getSession(); // ��ȡ�´�����SS 
                     HttpSession httpSession  = WebContextFactory.get().getSession();// ��ȡ����SS���û���HttpSession 
                     User user = (User)httpSession.getAttribute(SESSION_USER)
                     if(user ==null){ 
                             scriptSession.invalidate()
                             httpSession.invalidate()
                             return
                    
                     String ssId = (String) httpSession.getAttribute(SS_ID)
                     if (ssId != null) { 
                             DefaultScriptSession old=sessionMap.get(ssId)
                            if(old!=null)CustomSSManager.this.invalidate(old)
                    
                     httpSession.setAttribute(SS_ID, scriptSession.getId())
                     scriptSession.setAttribute("userId", user.getId());//�˴���userId��scriptSession�� 
            
             public void sessionDestroyed(ScriptSessionEvent event) {} 
          })
        ReqReverseAjax.manager=this;//���Լ���¶ReverseAjaxҵ������ 
View Full Code Here

    /**
     * Sets the script session for the game.
     */
    @Override
    public void setScriptSessionGame() {
        final ScriptSession scriptSession = WebContextFactory.get().getScriptSession();
        final HttpSession session = WebContextFactory.get().getSession();
        final Game game = (Game) session.getAttribute("game");
        final String email = (String) session.getAttribute("email");
        scriptSession.setAttribute("game", game);
        scriptSession.setAttribute("email", email);
    }
View Full Code Here

     * Used by the page unloader.
     */
    public void pageUnloaded()
    {
        WebContext wctx = WebContextFactory.get();
        ScriptSession scriptSession = wctx.getScriptSession();

        log.debug("pageUnloaded is invalidating scriptSession: " + scriptSession);
        scriptSession.invalidate();
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public void subscribe(String topic, String subscriptionId)
    {
        WebContext webContext = WebContextFactory.get();
        Hub hub = HubFactory.get();
        final ScriptSession session = webContext.getScriptSession();

        // Create a subscription block
        BrowserMessageListener subscription = new BrowserMessageListener(session, topic, subscriptionId);

        Map<String, BrowserMessageListener> subscriptions = (Map<String, BrowserMessageListener>) session.getAttribute(ATTRIBUTE_SUBSCRIPTIONS);
        if (subscriptions == null)
        {
            subscriptions = new HashMap<String, BrowserMessageListener>();
        }
        subscriptions.put(subscriptionId, subscription);
        session.setAttribute(ATTRIBUTE_SUBSCRIPTIONS, subscriptions);

        hub.subscribe(subscription.topic, subscription);
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public boolean unsubscribe(String subscriptionId)
    {
        WebContext webContext = WebContextFactory.get();
        Hub hub = HubFactory.get();
        ScriptSession session = webContext.getScriptSession();

        Map<String, BrowserMessageListener> subscriptions = (Map<String, BrowserMessageListener>) session.getAttribute(ATTRIBUTE_SUBSCRIPTIONS);
        BrowserMessageListener subscription = subscriptions.get(subscriptionId);

        return hub.unsubscribe(subscription.topic, subscription);
    }
View Full Code Here

    /* (non-Javadoc)
     * @see org.directwebremoting.AjaxFilter#doFilter(java.lang.Object, java.lang.reflect.Method, java.lang.Object[], org.directwebremoting.AjaxFilterChain)
     */
    public Object doFilter(Object obj, Method method, Object[] params, AjaxFilterChain chain) throws Exception
    {
        ScriptSession session = WebContextFactory.get().getScriptSession();
        Long lastAccess = (Long) session.getAttribute(ATTRIBUTE_LAST_ACTION);

        // Free pass in if you've not done anything so far.
        if (lastAccess != null)
        {
            long now = System.currentTimeMillis();
            if (now > lastAccess + actionTimeoutMillis)
            {
                session.addScript(new ScriptBuffer(onTimeout));
                session.invalidate();
                throw new DwrConvertedException("Your session has timed out");
            }
        }

        Object reply = chain.doFilter(obj, method, params);

        session.setAttribute(ATTRIBUTE_LAST_ACTION, System.currentTimeMillis());

        return reply;
    }
View Full Code Here

TOP

Related Classes of org.directwebremoting.ScriptSession

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.