如果您在當前會話對象存儲在本地,在說current_session
:
TorqueBox::Session::ServletStore.load_session_data(current_session)
這將允許您查看當前進程的數據,它是伴隨着一個妹妹功能這使您可以在還會話存儲設置數據,store_session_data(...)
:
TorqueBox::Session::ServletStore.store_session_data(current_session, data)
您還可以設置data
到{}
(空哈希)以使它無效(F或大多數意圖和目的)。
當前會話對象的可用性取決於範圍。例如,在一個stomplet,我必須做對用戶進行一番自我反省,以獲得current_session
對象才能看到會話數據:
class ChatStomplet
# ...
def on_subscribe (subscriber)
@subscribers[ session(subscriber)[:current_user].username ] << subscriber
end
# ...
def session (subscriber)
TorqueBox::Session::ServletStore.load_session_data(subscriber.getSession)
end
end
你或許應該有在ActionDispatch::Session::TorqueBoxStore
API偷看了。
我沒有親自找到這方面的文檔。事實上,我仍然在尋找一種方法來查找所有當前活動的會話。如果他們實現AbstractStore's interface,這將有所幫助,因爲與當前Rails約定的兼容性會很長。
我知道這是不是一個完整的答案,但希望它會闡明您的旅行一些輕..