-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb18138
commit abe078d
Showing
3 changed files
with
41 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Wamp | ||
module Connection | ||
# Client Session | ||
class Session | ||
attr_reader :joiner, :session, :store, :api | ||
attr_accessor :executor, :stream | ||
|
||
def initialize(joiner = Wampproto::Joiner.new("realm1")) | ||
@joiner = joiner | ||
@session = Wampproto::Session.new(joiner.serializer) | ||
@api = MessageHandler::Api.new(self) | ||
@store = {} | ||
end | ||
|
||
def on_join(&block) | ||
self.executor = block | ||
end | ||
|
||
def on_open | ||
stream.on_message joiner.send_hello | ||
end | ||
|
||
def on_message(data) | ||
handler = MessageHandler.resolve(data, self) | ||
handler.handle | ||
end | ||
|
||
def transmit(data) | ||
stream.on_message data | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.