hyper-operation 1.0.alpha1.8 → 1.0.0.lap28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -7
  3. data/.travis.yml +9 -21
  4. data/CODE_OF_CONDUCT.md +49 -0
  5. data/DOCS-POLICIES.md +582 -0
  6. data/DOCS.md +869 -0
  7. data/Gemfile +1 -5
  8. data/LICENSE.txt +21 -0
  9. data/README.md +77 -0
  10. data/Rakefile +2 -1
  11. data/dciy.toml +3 -0
  12. data/hyper-operation.gemspec +15 -19
  13. data/lib/hyper-operation.rb +6 -10
  14. data/lib/hyper-operation/api.rb +4 -8
  15. data/lib/hyper-operation/boot.rb +2 -3
  16. data/lib/hyper-operation/delay_and_interval.rb +9 -0
  17. data/lib/hyper-operation/engine.rb +2 -2
  18. data/lib/hyper-operation/exception.rb +4 -30
  19. data/lib/hyper-operation/filters/acting_user.rb +1 -1
  20. data/lib/hyper-operation/http.rb +2 -2
  21. data/lib/hyper-operation/promise.rb +2 -32
  22. data/lib/hyper-operation/railway.rb +1 -1
  23. data/lib/hyper-operation/railway/dispatcher.rb +5 -8
  24. data/lib/hyper-operation/railway/params_wrapper.rb +2 -2
  25. data/lib/hyper-operation/railway/run.rb +49 -58
  26. data/lib/hyper-operation/railway/validations.rb +3 -10
  27. data/lib/hyper-operation/server_op.rb +20 -46
  28. data/lib/hyper-operation/transport/action_cable.rb +8 -8
  29. data/lib/hyper-operation/transport/client_drivers.rb +55 -96
  30. data/lib/hyper-operation/transport/connection.rb +136 -58
  31. data/lib/hyper-operation/transport/{hyperstack.rb → hyperloop.rb} +15 -28
  32. data/lib/hyper-operation/transport/{hyperstack_controller.rb → hyperloop_controller.rb} +53 -59
  33. data/lib/hyper-operation/transport/policy.rb +49 -50
  34. data/lib/hyper-operation/version.rb +2 -2
  35. data/lib/sources/{hyperstack → hyperloop}/pusher.js +0 -0
  36. metadata +73 -94
  37. data/lib/hyper-operation/async_sleep.rb +0 -23
  38. data/lib/hyper-operation/transport/connection_adapter/active_record.rb +0 -113
  39. data/lib/hyper-operation/transport/connection_adapter/active_record/auto_create.rb +0 -26
  40. data/lib/hyper-operation/transport/connection_adapter/active_record/connection.rb +0 -47
  41. data/lib/hyper-operation/transport/connection_adapter/active_record/queued_message.rb +0 -42
  42. data/lib/hyper-operation/transport/connection_adapter/redis.rb +0 -94
  43. data/lib/hyper-operation/transport/connection_adapter/redis/connection.rb +0 -85
  44. data/lib/hyper-operation/transport/connection_adapter/redis/queued_message.rb +0 -34
  45. data/lib/hyper-operation/transport/connection_adapter/redis/redis_record.rb +0 -158
  46. data/lib/hyper-operation/transport/policy_diagnostics.rb +0 -106
@@ -1,95 +1,173 @@
1
- # frozen_string_literal: true
1
+ module Hyperloop
2
+ module AutoCreate
3
+ def table_exists?
4
+ # works with both rails 4 and 5 without deprecation warnings
5
+ if connection.respond_to?(:data_sources)
6
+ connection.data_sources.include?(table_name)
7
+ else
8
+ connection.tables.include?(table_name)
9
+ end
10
+ end
2
11
 
3
- module Hyperstack
4
- class Connection
5
- class << self
6
- attr_accessor :transport, :connection_adapter, :show_diagnostics
7
-
8
- def adapter
9
- adapter_name = Hyperstack.connection[:adapter].to_s
10
- adapter_path = "hyper-operation/transport/connection_adapter/#{adapter_name}"
11
-
12
- begin
13
- require adapter_path
14
- rescue LoadError => e
15
- if e.path == adapter_path
16
- raise e.class, "Could not load the '#{adapter_name}' adapter. Make sure the adapter is spelled correctly in your Hyperstack config, and the necessary gems are in your Gemfile.", e.backtrace
17
-
18
- # Bubbled up from the adapter require. Prefix the exception message
19
- # with some guidance about how to address it and reraise.
20
- else
21
- raise e.class, "Error loading the '#{adapter_name}' adapter. Missing a gem it depends on? #{e.message}", e.backtrace
22
- end
23
- end
12
+ def needs_init?
13
+ Hyperloop.transport != :none && Hyperloop.on_server? && !table_exists?
14
+ end
15
+
16
+ def create_table(*args, &block)
17
+ connection.create_table(table_name, *args, &block) if needs_init?
18
+ end
19
+ end
20
+
21
+ class Connection < ActiveRecord::Base
22
+ class QueuedMessage < ActiveRecord::Base
23
+
24
+ extend AutoCreate
25
+
26
+ self.table_name = 'hyperloop_queued_messages'
27
+
28
+ do_not_synchronize
24
29
 
25
- adapter_name = adapter_name.camelize
26
- "Hyperstack::ConnectionAdapter::#{adapter_name}".constantize
30
+ serialize :data
31
+
32
+ belongs_to :hyperloop_connection,
33
+ class_name: 'Hyperloop::Connection',
34
+ foreign_key: 'connection_id'
35
+
36
+ scope :for_session,
37
+ ->(session) { joins(:hyperloop_connection).where('session = ?', session) }
38
+
39
+ # For simplicity we use QueuedMessage with connection_id 0
40
+ # to store the current path which is used by consoles to
41
+ # communicate back to the server
42
+
43
+ default_scope { where('connection_id IS NULL OR connection_id != 0') }
44
+
45
+ def self.root_path=(path)
46
+ unscoped.find_or_create_by(connection_id: 0).update(data: path)
27
47
  end
28
48
 
29
- def build_tables
30
- adapter.build_tables
49
+ def self.root_path
50
+ unscoped.find_or_create_by(connection_id: 0).data
31
51
  end
52
+ end
32
53
 
33
- def build_tables?
34
- adapter.respond_to?(:build_tables)
54
+ extend AutoCreate
55
+
56
+ def self.build_tables
57
+ create_table(force: :cascade) do |t|
58
+ t.string :channel
59
+ t.string :session
60
+ t.datetime :created_at
61
+ t.datetime :expires_at
62
+ t.datetime :refresh_at
63
+ end
64
+ QueuedMessage.create_table(force: :cascade) do |t|
65
+ t.text :data
66
+ t.integer :connection_id
35
67
  end
68
+ end
36
69
 
37
- def active
38
- adapter.active
70
+ do_not_synchronize
71
+
72
+ self.table_name = 'hyperloop_connections'
73
+
74
+ has_many :messages,
75
+ foreign_key: 'connection_id',
76
+ class_name: 'Hyperloop::Connection::QueuedMessage',
77
+ dependent: :destroy
78
+ scope :expired,
79
+ -> { where('expires_at IS NOT NULL AND expires_at < ?', Time.zone.now) }
80
+ scope :pending_for,
81
+ ->(channel) { where(channel: channel).where('session IS NOT NULL') }
82
+ scope :inactive,
83
+ -> { where('session IS NULL AND refresh_at < ?', Time.zone.now) }
84
+
85
+ def self.needs_refresh?
86
+ exists?(['refresh_at IS NOT NULL AND refresh_at < ?', Time.zone.now])
87
+ end
88
+
89
+ def transport
90
+ self.class.transport
91
+ end
92
+
93
+ before_create do
94
+ if session
95
+ self.expires_at = Time.now + transport.expire_new_connection_in
96
+ elsif transport.refresh_channels_every != :never
97
+ self.refresh_at = Time.now + transport.refresh_channels_every
39
98
  end
99
+ end
40
100
 
41
- def open(channel, session = nil, root_path = nil)
42
- puts "open(#{channel}, #{session}, #{root_path})" if show_diagnostics
101
+ class << self
102
+ attr_accessor :transport
43
103
 
44
- adapter.open(channel, session, root_path).tap do |c|
45
- puts " - open returning #{c}" if show_diagnostics
104
+ def active
105
+ # if table doesn't exist then we are either calling from within
106
+ # a migration or from a console before the server has ever started
107
+ # in these cases there are no channels so we return nothing
108
+ return [] unless table_exists?
109
+ if Hyperloop.on_server?
110
+ expired.delete_all
111
+ refresh_connections if needs_refresh?
46
112
  end
113
+ all.pluck(:channel).uniq
47
114
  end
48
115
 
49
- def send_to_channel(channel, data)
50
- puts "send_to_channel(#{channel}, #{data})" if show_diagnostics
116
+ def open(channel, session = nil, root_path = nil)
117
+ self.root_path = root_path
118
+ find_or_create_by(channel: channel, session: session)
119
+ end
51
120
 
52
- adapter.send_to_channel(channel, data)
121
+ def send_to_channel(channel, data)
122
+ pending_for(channel).each do |connection|
123
+ QueuedMessage.create(data: data, hyperloop_connection: connection)
124
+ end
125
+ transport.send_data(channel, data) if exists?(channel: channel, session: nil)
53
126
  end
54
127
 
55
128
  def read(session, root_path)
56
- puts "read(#{session}, #{root_path})" if show_diagnostics
57
-
58
- adapter.read(session, root_path)
129
+ self.root_path = root_path
130
+ where(session: session)
131
+ .update_all(expires_at: Time.now + transport.expire_polled_connection_in)
132
+ QueuedMessage.for_session(session).destroy_all.pluck(:data)
59
133
  end
60
134
 
61
135
  def connect_to_transport(channel, session, root_path)
62
- puts "connect_to_transport(#{channel}, #{session}, #{root_path})" if show_diagnostics
63
-
64
- adapter.connect_to_transport(channel, session, root_path)
136
+ self.root_path = root_path
137
+ if (connection = find_by(channel: channel, session: session))
138
+ messages = connection.messages.pluck(:data)
139
+ connection.destroy
140
+ else
141
+ messages = []
142
+ end
143
+ open(channel)
144
+ messages
65
145
  end
66
146
 
67
147
  def disconnect(channel)
68
- adapter.disconnect(channel)
148
+ find_by(channel: channel, session: nil).destroy
69
149
  end
70
150
 
71
151
  def root_path=(path)
72
- adapter.root_path = path
152
+ QueuedMessage.root_path = path if path
73
153
  end
74
154
 
75
155
  def root_path
76
- adapter.root_path
156
+ # if the QueuedMessage table doesn't exist then we are either calling from within
157
+ # a migration or from a console before the server has ever started
158
+ # in these cases there is no root path to the server
159
+ QueuedMessage.root_path if QueuedMessage.table_exists?
77
160
  end
78
161
 
79
162
  def refresh_connections
80
- adapter.refresh_connections
81
- end
82
-
83
- def method_missing(method_name, *args, &block)
84
- if adapter::Connection.respond_to?(method_name)
85
- adapter::Connection.send(method_name, *args, &block)
86
- else
87
- super
163
+ refresh_started_at = Time.zone.now
164
+ channels = transport.refresh_channels
165
+ next_refresh = refresh_started_at + transport.refresh_channels_every
166
+ channels.each do |channel|
167
+ connection = find_by(channel: channel, session: nil)
168
+ connection.update(refresh_at: next_refresh) if connection
88
169
  end
89
- end
90
-
91
- def respond_to_missing?(method_name, include_private = false)
92
- adapter::Connection.respond_to?(method_name)
170
+ inactive.delete_all
93
171
  end
94
172
  end
95
173
  end
@@ -1,6 +1,6 @@
1
1
  # Provides the configuration and the two basic routines for the server
2
2
  # to indicate that records have changed: after_change and after_destroy
3
- module Hyperstack
3
+ module Hyperloop
4
4
 
5
5
  def self.initialize_policies
6
6
  reset_operations unless @config_reset_called
@@ -13,10 +13,10 @@ module Hyperstack
13
13
  def self.reset_operations
14
14
  @config_reset_called = true
15
15
  Rails.configuration.tap do |config|
16
- # config.eager_load_paths += %W(#{config.root}/app/hyperstack/models)
17
- # config.autoload_paths += %W(#{config.root}/app/hyperstack/models)
18
- # config.assets.paths << ::Rails.root.join('app', 'hyperstack').to_s
19
- config.after_initialize { Connection.build_tables if Connection.build_tables? }
16
+ # config.eager_load_paths += %W(#{config.root}/app/hyperloop/models)
17
+ # config.autoload_paths += %W(#{config.root}/app/hyperloop/models)
18
+ # config.assets.paths << ::Rails.root.join('app', 'hyperloop').to_s
19
+ config.after_initialize { Connection.build_tables }
20
20
  end
21
21
  Object.send(:remove_const, :Application) if @fake_application_defined
22
22
  @fake_application_defined = false
@@ -37,10 +37,10 @@ module Hyperstack
37
37
  @fake_application_defined = true
38
38
  end
39
39
  begin
40
- Object.const_get 'Hyperstack::ApplicationPolicy'
40
+ Object.const_get 'Hyperloop::ApplicationPolicy'
41
41
  rescue LoadError
42
42
  rescue NameError => e
43
- raise e unless e.message =~ /uninitialized constant Hyperstack::ApplicationPolicy/
43
+ raise e unless e.message =~ /uninitialized constant Hyperloop::ApplicationPolicy/
44
44
  end
45
45
  @pusher = nil
46
46
  end
@@ -49,31 +49,21 @@ module Hyperstack
49
49
  if transport == :action_cable
50
50
  require 'hyper-operation/transport/action_cable'
51
51
  opts[:refresh_channels_every] = :never
52
- import 'action_cable', client_only: true if Rails.configuration.hyperstack.auto_config
52
+ import 'action_cable', client_only: true if Rails.configuration.hyperloop.auto_config
53
53
  elsif transport == :pusher
54
54
  require 'pusher'
55
- import 'hyperstack/pusher', client_only: true if Rails.configuration.hyperstack.auto_config
55
+ import 'hyperloop/pusher', client_only: true if Rails.configuration.hyperloop.auto_config
56
56
  opts[:refresh_channels_every] = nil if opts[:refresh_channels_every] == :never
57
57
  else
58
58
  opts[:refresh_channels_every] = nil if opts[:refresh_channels_every] == :never
59
59
  end
60
60
  end
61
61
 
62
- define_setting(:send_to_server_timeout, 10)
63
-
64
62
  define_setting :opts, {}
65
63
  define_setting :channel_prefix, 'synchromesh'
66
64
  define_setting :client_logging, true
67
65
  define_setting :connect_session, true
68
66
 
69
- define_setting(:connection, { adapter: :active_record }) do |connection|
70
- if connection[:adapter] == :redis
71
- require 'redis'
72
-
73
- connection[:redis_url] ||= 'redis://127.0.0.1:6379/hyperstack'
74
- end
75
- end
76
-
77
67
  def self.app_id
78
68
  opts[:app_id] || Pusher.app_id if transport == :pusher
79
69
  end
@@ -117,7 +107,7 @@ module Hyperstack
117
107
 
118
108
  def self.refresh_channels
119
109
  new_channels = pusher.channels[:channels].collect do |channel, _etc|
120
- channel.gsub(/^#{Regexp.quote(Hyperstack.channel)}\-/, '').gsub('==', '::')
110
+ channel.gsub(/^#{Regexp.quote(Hyperloop.channel)}\-/, '').gsub('==', '::')
121
111
  end
122
112
  end
123
113
 
@@ -125,9 +115,9 @@ module Hyperstack
125
115
  if !on_server?
126
116
  send_to_server(channel, data)
127
117
  elsif transport == :pusher
128
- pusher.trigger("#{Hyperstack.channel}-#{data[1][:channel].gsub('::', '==')}", *data)
118
+ pusher.trigger("#{Hyperloop.channel}-#{data[1][:channel].gsub('::', '==')}", *data)
129
119
  elsif transport == :action_cable
130
- ActionCable.server.broadcast("hyperstack-#{channel}", message: data[0], data: data[1])
120
+ ActionCable.server.broadcast("hyperloop-#{channel}", message: data[0], data: data[1])
131
121
  end
132
122
  end
133
123
 
@@ -173,15 +163,12 @@ module Hyperstack
173
163
  request.body = {
174
164
  channel: channel, data: data, salt: salt, authorization: authorization
175
165
  }.to_json
176
- Timeout::timeout(Hyperstack.send_to_server_timeout) { http.request(request) }
177
- rescue Timeout::Error
178
- puts "\n********* FAILED TO RECEIVE RESPONSE FROM SERVER WITHIN #{Hyperstack.send_to_server_timeout} SECONDS. CHANGES WILL NOT BE SYNCED ************\n"
179
- raise 'no server running'
166
+ http.request(request)
180
167
  end
181
168
 
182
169
  def self.dispatch(data)
183
- if !Hyperstack.on_server? && Connection.root_path
184
- Hyperstack.send_to_server(data[:channel], [:dispatch, data])
170
+ if !Hyperloop.on_server? && Connection.root_path
171
+ Hyperloop.send_to_server(data[:channel], [:dispatch, data])
185
172
  else
186
173
  Connection.send_to_channel(data[:channel], [:dispatch, data])
187
174
  end
@@ -1,6 +1,6 @@
1
- module Hyperstack
2
- ::Hyperstack::Engine.routes.append do
3
- Hyperstack.initialize_policies
1
+ module Hyperloop
2
+ ::Hyperloop::Engine.routes.append do
3
+ Hyperloop.initialize_policies
4
4
 
5
5
  module ::WebConsole
6
6
  class Middleware
@@ -11,22 +11,18 @@ module Hyperstack
11
11
  end
12
12
  end if defined? ::WebConsole::Middleware
13
13
 
14
-
15
- # The purpose of this is to prevent massive amounts of logging
16
- # if using simple polling. If polling is on then only actual messages
17
- # with content will be shown, other wise the log message is dropped.
18
14
  module ::Rails
19
15
  module Rack
20
16
  class Logger < ActiveSupport::LogSubscriber
21
- unless method_defined? :pre_hyperstack_call
22
- alias pre_hyperstack_call call
17
+ unless method_defined? :pre_hyperloop_call
18
+ alias pre_hyperloop_call call
23
19
  def call(env)
24
- if Hyperstack.transport == :simple_poller && env['PATH_INFO'] && env['PATH_INFO'].include?('/hyperstack-read/')
20
+ if Hyperloop.transport == :simple_poller && env['PATH_INFO'] && env['PATH_INFO'].include?('/hyperloop-read/')
25
21
  Rails.logger.silence do
26
- pre_hyperstack_call(env)
22
+ pre_hyperloop_call(env)
27
23
  end
28
24
  else
29
- pre_hyperstack_call(env)
25
+ pre_hyperloop_call(env)
30
26
  end
31
27
  end
32
28
  end
@@ -34,7 +30,7 @@ module Hyperstack
34
30
  end
35
31
  end if defined?(::Rails::Rack::Logger)
36
32
 
37
- class HyperstackController < ::ApplicationController
33
+ class HyperloopController < ::ApplicationController
38
34
 
39
35
  protect_from_forgery except: [:console_update, :execute_remote_api]
40
36
 
@@ -43,28 +39,28 @@ module Hyperstack
43
39
  end
44
40
 
45
41
  before_action do
46
- session.delete 'hyperstack-dummy-init' unless session.id
42
+ session.delete 'hyperloop-dummy-init' unless session.id
47
43
  end
48
44
 
49
45
  def session_channel
50
- "Hyperstack::Session-#{session.id}"
46
+ "Hyperloop::Session-#{session.id}"
51
47
  end
52
48
 
53
49
  def regulate(channel)
54
- unless channel == session_channel # "Hyperstack::Session-#{client_id.split('-').last}"
55
- Hyperstack::InternalPolicy.regulate_connection(try(:acting_user), channel)
50
+ unless channel == session_channel # "Hyperloop::Session-#{client_id.split('-').last}"
51
+ Hyperloop::InternalPolicy.regulate_connection(try(:acting_user), channel)
56
52
  end
57
53
  channel
58
54
  end
59
55
 
60
56
  def channels(user = acting_user, session_id = session.id)
61
- Hyperstack::AutoConnect.channels(session_id, user)
57
+ Hyperloop::AutoConnect.channels(session_id, user)
62
58
  end
63
59
 
64
60
  def can_connect?(channel, user = acting_user)
65
- Hyperstack::InternalPolicy.regulate_connection(
61
+ Hyperloop::InternalPolicy.regulate_connection(
66
62
  user,
67
- Hyperstack::InternalPolicy.channel_to_string(channel)
63
+ Hyperloop::InternalPolicy.channel_to_string(channel)
68
64
  )
69
65
  true
70
66
  rescue
@@ -105,47 +101,45 @@ module Hyperstack
105
101
 
106
102
  def subscribe
107
103
  channel = regulate params[:channel].gsub('==', '::')
108
- root_path = request.original_url.gsub(/hyperstack-subscribe.*$/, '')
109
- Hyperstack::Connection.open(channel, client_id, root_path)
104
+ root_path = request.original_url.gsub(/hyperloop-subscribe.*$/, '')
105
+ Hyperloop::Connection.open(channel, client_id, root_path)
110
106
  head :ok
111
107
  rescue Exception
112
108
  head :unauthorized
113
109
  end
114
110
 
115
111
  def read
116
- root_path = request.original_url.gsub(/hyperstack-read.*$/, '')
117
- data = Hyperstack::Connection.read(client_id, root_path)
112
+ root_path = request.original_url.gsub(/hyperloop-read.*$/, '')
113
+ data = Hyperloop::Connection.read(client_id, root_path)
118
114
  render json: data
119
115
  end
120
116
 
121
117
  def pusher_auth
122
- raise unless Hyperstack.transport == :pusher
123
- channel = regulate params[:channel_name].gsub(/^#{Regexp.quote(Hyperstack.channel)}\-/,'').gsub('==', '::')
124
- response = Hyperstack.pusher.authenticate(params[:channel_name], params[:socket_id])
118
+ raise unless Hyperloop.transport == :pusher
119
+ channel = regulate params[:channel_name].gsub(/^#{Regexp.quote(Hyperloop.channel)}\-/,'').gsub('==', '::')
120
+ response = Hyperloop.pusher.authenticate(params[:channel_name], params[:socket_id])
125
121
  render json: response
126
122
  rescue Exception => e
127
123
  head :unauthorized
128
124
  end
129
125
 
130
126
  def action_cable_auth
131
- raise unless Hyperstack.transport == :action_cable
132
- channel = regulate params[:channel_name].gsub(/^#{Regexp.quote(Hyperstack.channel)}\-/,'')
127
+ raise unless Hyperloop.transport == :action_cable
128
+ channel = regulate params[:channel_name].gsub(/^#{Regexp.quote(Hyperloop.channel)}\-/,'')
133
129
  salt = SecureRandom.hex
134
- authorization = Hyperstack.authorization(salt, channel, client_id)
130
+ authorization = Hyperloop.authorization(salt, channel, client_id)
135
131
  render json: {authorization: authorization, salt: salt}
136
132
  rescue Exception
137
133
  head :unauthorized
138
134
  end
139
135
 
140
136
  def connect_to_transport
141
- root_path = request.original_url.gsub(/hyperstack-connect-to-transport.*$/, '')
142
- render json: Hyperstack::Connection.connect_to_transport(params[:channel], client_id, root_path)
143
- rescue Exception => e
144
- render status: :service_unavailable, json: {error: e}
137
+ root_path = request.original_url.gsub(/hyperloop-connect-to-transport.*$/, '')
138
+ render json: Hyperloop::Connection.connect_to_transport(params[:channel], client_id, root_path)
145
139
  end
146
140
 
147
141
  def execute_remote
148
- parsed_params = JSON.parse(params[:hyperstack_secured_json]).symbolize_keys
142
+ parsed_params = JSON.parse(params[:json]).symbolize_keys
149
143
  render ServerOp.run_from_client(
150
144
  :acting_user,
151
145
  self,
@@ -157,15 +151,15 @@ module Hyperstack
157
151
  def execute_remote_api
158
152
  params.require(:params).permit!
159
153
  parsed_params = params[:params].to_h.symbolize_keys
160
- raise AccessViolation.new(:illegal_remote_api_call) unless parsed_params[:authorization]
154
+ raise AccessViolation unless parsed_params[:authorization]
161
155
  render ServerOp.run_from_client(:authorization, self, params[:operation], parsed_params)
162
156
  end
163
157
 
164
158
  def console_update # TODO this should just become an execute-remote-api call
165
159
  raise unless Rails.env.development?
166
- authorization = Hyperstack.authorization(params[:salt], params[:channel], params[:data][1][:broadcast_id]) #params[:data].to_json)
160
+ authorization = Hyperloop.authorization(params[:salt], params[:channel], params[:data][1][:broadcast_id]) #params[:data].to_json)
167
161
  return head :unauthorized if authorization != params[:authorization]
168
- Hyperstack::Connection.send_to_channel(params[:channel], params[:data])
162
+ Hyperloop::Connection.send_to_channel(params[:channel], params[:data])
169
163
  head :no_content
170
164
  rescue
171
165
  head :unauthorized
@@ -175,32 +169,32 @@ module Hyperstack
175
169
  head :no_content
176
170
  end
177
171
 
178
- end unless defined? Hyperstack::HyperstackController
172
+ end unless defined? Hyperloop::HyperloopController
179
173
 
180
174
  match 'execute_remote',
181
- to: 'hyperstack#execute_remote', via: :post
175
+ to: 'hyperloop#execute_remote', via: :post
182
176
  match 'execute_remote_api',
183
- to: 'hyperstack#execute_remote_api', via: :post
184
-
185
- # match 'hyperstack-subscribe',
186
- # to: 'hyperstack#subscribe', via: :get
187
- # match 'hyperstack-read/:subscriber',
188
- # to: 'hyperstack#read', via: :get
189
- match 'hyperstack-subscribe/:client_id/:channel',
190
- to: 'hyperstack#subscribe', via: :get
191
- match 'hyperstack-read/:client_id',
192
- to: 'hyperstack#read', via: :get
193
- match 'hyperstack-pusher-auth',
194
- to: 'hyperstack#pusher_auth', via: :post
195
- match 'hyperstack-action-cable-auth/:client_id/:channel_name',
196
- to: 'hyperstack#action_cable_auth', via: :post
197
- match 'hyperstack-connect-to-transport/:client_id/:channel',
198
- to: 'hyperstack#connect_to_transport', via: :get
177
+ to: 'hyperloop#execute_remote_api', via: :post
178
+
179
+ # match 'hyperloop-subscribe',
180
+ # to: 'hyperloop#subscribe', via: :get
181
+ # match 'hyperloop-read/:subscriber',
182
+ # to: 'hyperloop#read', via: :get
183
+ match 'hyperloop-subscribe/:client_id/:channel',
184
+ to: 'hyperloop#subscribe', via: :get
185
+ match 'hyperloop-read/:client_id',
186
+ to: 'hyperloop#read', via: :get
187
+ match 'hyperloop-pusher-auth',
188
+ to: 'hyperloop#pusher_auth', via: :post
189
+ match 'hyperloop-action-cable-auth/:client_id/:channel_name',
190
+ to: 'hyperloop#action_cable_auth', via: :post
191
+ match 'hyperloop-connect-to-transport/:client_id/:channel',
192
+ to: 'hyperloop#connect_to_transport', via: :get
199
193
  match 'console',
200
- to: 'hyperstack#debug_console', via: :get
194
+ to: 'hyperloop#debug_console', via: :get
201
195
  match 'console_update',
202
- to: 'hyperstack#console_update', via: :post
196
+ to: 'hyperloop#console_update', via: :post
203
197
  match 'server_up',
204
- to: 'hyperstack#server_up', via: :get
198
+ to: 'hyperloop#server_up', via: :get
205
199
  end
206
200
  end