Skip to content

Commit

Permalink
Merge pull request #12 from xconnio/integrate-wampproto
Browse files Browse the repository at this point in the history
Integrate "wampproto.rb" gem for client APIs
  • Loading branch information
rubyonrails3 authored May 30, 2024
2 parents ab5636a + e588291 commit 17dd39b
Show file tree
Hide file tree
Showing 74 changed files with 1,218 additions and 1,718 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ gem "rspec", "~> 3.0"
gem "rubocop", "~> 1.21"

gem "async", "~> 2.9"

gem "wampproto", github: "xconnio/wampproto.rb", branch: :main, require: true
7 changes: 3 additions & 4 deletions lib/wamp.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# frozen_string_literal: true

require_relative "wamp/version"
require_relative "wamp/connection/base"
require_relative "wamp/message_handler"
require_relative "wamp/connection/session"
require_relative "wamp/connection/websocket_connection"
require_relative "wamp/serializer"
require_relative "wamp/router"
require_relative "wamp/message"
require_relative "wamp/manager"
require_relative "wamp/auth"

module Wamp
class Error < StandardError; end
Expand Down
11 changes: 0 additions & 11 deletions lib/wamp/auth.rb

This file was deleted.

21 changes: 0 additions & 21 deletions lib/wamp/auth/anonymous.rb

This file was deleted.

49 changes: 0 additions & 49 deletions lib/wamp/auth/cra.rb

This file was deleted.

81 changes: 0 additions & 81 deletions lib/wamp/auth/cryptosign.rb

This file was deleted.

34 changes: 0 additions & 34 deletions lib/wamp/auth/ticket.rb

This file was deleted.

88 changes: 0 additions & 88 deletions lib/wamp/connection/base.rb

This file was deleted.

35 changes: 35 additions & 0 deletions lib/wamp/connection/session.rb
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
Loading

0 comments on commit 17dd39b

Please sign in to comment.