I’m attempting to retrieve a url parameter within a CometActor to validate that the source of the data matches the destination, e.g A user sends a message from room A, which should be received and displayed only in room A, not B or C.
I’ve tried:
S.param("message").openOr("")
But it’s always empty, can this be done? Or is there another way to stop Comet messages going where they shouldn’t?
Thanks in advance for any help, much appreciated 🙂
CometActors exist outside of the session and so don’t have access to (most of) it. The solution is to initialize the actor with an initialization message containing the desired session data. There’s some sort of helper, perhaps in LiftRules, to do that. I’m on my phone and recounting this from memory but hopefully it’s enough to go on.
Specifically, you’re going to want to do something like:
in your
Boot.scala.Check out
LiftSessionfor a little more. I think there might be a way to hook intoLiftRulesto have the relevant code called upon session creation…Update: And here’s what your CometActor might look like if we send a case class containing: