class Session extends wamp.Session with SessionIdScope
Represents a session attached to a realm.
Open
Instances are created either by invoking the Connection.open or the Client.open method
val conn: Future[Connection] = ... val session: Future[Session] = conn.flatMap(c => c.open("myrealm"))
Topics
Once the session is open, you can publish to topics.
val publication: Future[Publication] = session.flatMap { s => s.publish("mytopic", List("paolo", 40)) }
Or you can subscribe event consumers to topics.
val subscription: Future[Subscription] = session.flatMap { s => s.subscribe("mytopic", event => { val publicationId = event.publicationId val subscriptionId = event.subscriptionId val details = event.details val payload = event.payload // consume payload content ... }) }
Procedures
Once opened, you can call procedures.
val result: Future[Result] = session.flatMap(s => s.call("myprocedure", List("paolo", 99)))
Or you can register invocation handlers as procedures.
val registration: Future[Registration] = session.flatMap { s => s.register("myprocedure", invocation => { val registrationId = invocation.registrationId val details = event.details val payload = event.payload // handle payload content ... // return future of payload ... }) }
Macros
You can subscribe/register lambda consumers/handlers to make your code look more functional ;-)
val subscription: Future[Subscription] = session.flatMap { implicit s => publish("mytopic", List("paolo", 40)) subscribe("mytopic", (name: String, age: Int) => { println(s"$name is $age years old") }) register("myprocedure", (name: String, age: Int) => { name.length + age }) }
- See also
- Alphabetic
- By Inheritance
- Session
- SessionIdScope
- IdScope
- Session
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
call(procedure: Uri, kwargs: Map[String, Any]): Future[Result]
Calls the given procedure with the given dictionary of named arguments
Calls the given procedure with the given dictionary of named arguments
- procedure
is the procedure to be called
- kwargs
the dictionary of named arguments
- returns
the (future of) result
-
def
call(procedure: Uri, args: List[Any]): Future[Result]
Calls the given procedure with the given list of indexed arguments
Calls the given procedure with the given list of indexed arguments
- procedure
is the procedure to be called
- args
the list of indexed arguments
- returns
the (future of) result
-
def
call(procedure: Uri): Future[Result]
Calls the given procedure
Calls the given procedure
- procedure
is the procedure to be called
- returns
the (future of) result
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
close(reason: Uri, details: Dict): Future[Closed]
Closes this session with the given reason and additional details.
Closes this session with the given reason and additional details.
- reason
is the reason to close
- details
are the details to send
- returns
the (future of) closed signal
-
def
close(reason: Uri): Future[Closed]
Closes this session with the given reason and default empty details.
Closes this session with the given reason and default empty details.
- reason
is the reason to close
- returns
the (future of) closed signal
-
def
close(): Future[Closed]
Closes this session with
as reason and default empty details."wamp.error.close_realm"
Closes this session with
as reason and default empty details."wamp.error.close_realm"
- returns
the (future of) closed signal
-
val
connector: ActorRef
- Attributes
- protected
-
val
details: Dict
Are addtional details about this session as sent by the router
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
generate(oldIds: Set[Id], fn: (Id) ⇒ Id): Id
- Attributes
- protected
- Definition Classes
- IdScope
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
val
id: Id
Is this session unique identifier as sent by the router
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
nextRequestId(excludes: Set[Id]): Id
Generate the next identifier within this scope excluding the provided ones
Generate the next identifier within this scope excluding the provided ones
- excludes
is the identifiers set to be excluded
- returns
the next identifier
- Definition Classes
- SessionIdScope → IdScope
-
def
nextRequestId(): Id
Generate the next identifier within this scope
Generate the next identifier within this scope
- returns
the next identifier
- Definition Classes
- IdScope
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
publish(topic: Uri, kwargs: Map[String, Any]): Unit
Publish to a topic (fire and forget)
Publish to a topic (fire and forget)
- topic
is the topic to publish to
- kwargs
is the dictionary of named arguments to be published
-
def
publish(topic: Uri, args: List[Any]): Unit
Publish to a topic (fire and forget)
Publish to a topic (fire and forget)
- topic
is the topic to publish to
- args
is the list of indexed arguments to be published
-
def
publish(topic: Uri): Unit
Publish to a topic (fire and forget)
Publish to a topic (fire and forget)
- topic
is the topic to publish to
-
def
publishAck(topic: Uri, kwargs: Map[String, Any]): Future[Publication]
Publish to a topic (and acknowledge)
Publish to a topic (and acknowledge)
- topic
is the topic to publish to
- kwargs
is the dictionary of named arguments to be published
- returns
the (future of) publication acknowledgment
-
def
publishAck(topic: Uri, args: List[Any]): Future[Publication]
Publish to a topic (and acknowledge)
Publish to a topic (and acknowledge)
- topic
is the topic to publish to
- args
is the list of indexed arguments to be published
- returns
the (future of) publication acknowledgment
-
def
publishAck(topic: Uri): Future[Publication]
Publish to a topic (and acknowledge)
Publish to a topic (and acknowledge)
- topic
is the topic to publish to
- returns
the (future of) publication acknowledgment
-
val
realm: Uri
Is the realm this session is attached to
-
def
register(procedure: Uri, handler: (Invocation) ⇒ Future[Payload]): Future[Registration]
Registers the given invocation handler as the given procedure
Registers the given invocation handler as the given procedure
- procedure
is the procedure to register as
- handler
is the invocation handler which will handle incoming invocations
- returns
the (future of) registration
- See also
-
def
subscribe(topic: Uri, consumer: (Event) ⇒ Future[Done]): Future[Subscription]
Subscribes the given event consumer to the given topic
Subscribes the given event consumer to the given topic
- topic
is the topic to subscribe to
- consumer
is the event consumer which will consume incoming events
- returns
the (future of) subscription
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )