Git Product home page Git Product logo

Comments (11)

FrEaKmAn avatar FrEaKmAn commented on June 14, 2024

Anything new regarding this problem?

from atmosphere-play.

jfarcand avatar jfarcand commented on June 14, 2024

Can you point me to the Play Session? I will implements that API

from atmosphere-play.

FrEaKmAn avatar FrEaKmAn commented on June 14, 2024

Would it be possible to parse PLAY_SESSION cookie and identify user? Logic for this is stored at https://github.com/playframework/playframework/blob/master/framework/src/play/src/main/scala/play/api/mvc/Http.scala#L710

from atmosphere-play.

vkoop avatar vkoop commented on June 14, 2024

Hi, is there any progress on sessions? You could access the session inside of "AtmosphereController".....session() would Provide the Play Session.

from atmosphere-play.

jfarcand avatar jfarcand commented on June 14, 2024

@vkoop Contribution welcomed!

from atmosphere-play.

rafalfaron avatar rafalfaron commented on June 14, 2024

I am not sure if accessing pure play session object in atmosphere would be good idea (Its http request scoped AFAIK)

Here are my changes with hook in form of AtmospherePlaySessionConverter in which anyone can translate what they want from play session into AtmopshereRequest.attributes. #19

Its pretty rough, but gives basic idea.

from atmosphere-play.

daut-morina avatar daut-morina commented on June 14, 2024

Is there any news on this? Still returns null.

from atmosphere-play.

jfarcand avatar jfarcand commented on June 14, 2024

@daut-morina Have you tested the latest version?

from atmosphere-play.

daut-morina avatar daut-morina commented on June 14, 2024

@jfarcand Thanks for your quick reply.

Yes, I'm using 2.1.0 on Play 2.3. Is session support enabled by default or do I have to enable it first like I would have to when using the generic atmosphere framework?

Update
On startup I see following log entry:
[info] o.a.c.AtmosphereFramework - HttpSession supported: false
So the session is not enabled, but i couldn't find any documentation about how to enable the session in play since there's no web.xml in play.

from atmosphere-play.

daut-morina avatar daut-morina commented on June 14, 2024

In the play chat example in Global.java I do following:

@Override
public void onStart(Application application) {
    instance().framework().getAtmosphereConfig().setSupportSession(true);
    instance().discover(Chat.class).ready();
}

and now the log shows:

[info] o.a.c.AtmosphereFramework - HttpSession supported: true

The result is that following:

@Ready
public void onReady(final AtmosphereResource r) {
    logger.info("Session: " + r.session());
    logger.info("Session from request: " + r.getRequest().getSession());
    logger.info("Cookie from request: " + r.getRequest().getCookies().length);
}

gives you this:

[info] o.a.s.play.Chat - Session: org.atmosphere.cpr.AtmosphereRequest$NoOpsRequest$1@6c7c94c3
[info] o.a.s.play.Chat - Session: org.atmosphere.cpr.AtmosphereRequest$NoOpsRequest$1@6c7c94c3
[info] o.a.s.play.Chat - Session: 0

from atmosphere-play.

rafalfaron avatar rafalfaron commented on June 14, 2024

@daut-morina
pull request I provided above was merged to play-atmoshpere 2+ - it introduces hook in form of AtmospherePlaySessionConverter for play session access from atmosphere parts.

It will not just give you access to full play HTTP session, but rather provides a hook where you can read some values from it and put it as attributes of Atmoshphere request.

(There is no default implementation of AtmospherePlaySessionConverter, you need to prepare any that will work for you and hook it via properties ("org.atmopshere.play.AtmospherePlaySessionConverter" property) - just watch out for problems with them under play development mode ())

See also

I use this hook in my projects to access play-authenticate sessions and it works fine.

from atmosphere-play.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.