procon_bypass_man 0.1.14 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -0
  3. data/.github/workflows/release.yml +33 -0
  4. data/CHANGELOG.md +15 -0
  5. data/Gemfile +1 -0
  6. data/Gemfile.lock +28 -7
  7. data/README.md +26 -3
  8. data/Steepfile +31 -17
  9. data/docs/setting/left-analogstick-cap.md +60 -0
  10. data/docs/setup_raspi.md +2 -0
  11. data/docs/setup_raspi.mitamae.rb +7 -8
  12. data/docs/setup_raspi_by_mitamae.md +37 -1
  13. data/lib/ext/em_pure_ruby.rb +25 -0
  14. data/lib/procon_bypass_man/background.rb +0 -1
  15. data/lib/procon_bypass_man/buttons_setting_configuration/layer.rb +35 -13
  16. data/lib/procon_bypass_man/buttons_setting_configuration/loader.rb +1 -0
  17. data/lib/procon_bypass_man/buttons_setting_configuration/validator.rb +36 -0
  18. data/lib/procon_bypass_man/buttons_setting_configuration.rb +28 -13
  19. data/lib/procon_bypass_man/bypass/usb_hid_logger.rb +6 -4
  20. data/lib/procon_bypass_man/bypass.rb +13 -6
  21. data/lib/procon_bypass_man/commands/print_boot_message_command.rb +50 -1
  22. data/lib/procon_bypass_man/commands/print_message_command.rb +8 -0
  23. data/lib/procon_bypass_man/commands/run_remote_pbm_action_dispatch_command.rb +3 -1
  24. data/lib/procon_bypass_man/commands/send_reload_config_event_command.rb +1 -2
  25. data/lib/procon_bypass_man/commands.rb +1 -0
  26. data/lib/procon_bypass_man/configuration.rb +32 -1
  27. data/lib/procon_bypass_man/domains/binary/base.rb +25 -0
  28. data/lib/procon_bypass_man/domains/binary/has_immutable_binary.rb +5 -0
  29. data/lib/procon_bypass_man/domains/binary/has_mutable_binary.rb +5 -0
  30. data/lib/procon_bypass_man/domains/binary/inbound_procon_binary.rb +9 -0
  31. data/lib/procon_bypass_man/domains/binary/processing_procon_binary.rb +66 -0
  32. data/lib/procon_bypass_man/domains.rb +11 -0
  33. data/lib/procon_bypass_man/plugin/splatoon2/macro/fast_return.rb +17 -0
  34. data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_left_key.rb +17 -0
  35. data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_right_key.rb +17 -0
  36. data/lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_up_key.rb +17 -0
  37. data/lib/procon_bypass_man/plugin/splatoon2/mode/guruguru.rb +59 -0
  38. data/lib/procon_bypass_man/plugin/splatoon2/version.rb +9 -0
  39. data/lib/procon_bypass_man/plugins.rb +11 -0
  40. data/lib/procon_bypass_man/processor.rb +4 -5
  41. data/lib/procon_bypass_man/procon/button.rb +11 -0
  42. data/lib/procon_bypass_man/procon/button_collection.rb +9 -11
  43. data/lib/procon_bypass_man/procon/layer_changer.rb +3 -2
  44. data/lib/procon_bypass_man/procon/macro_registry.rb +8 -5
  45. data/lib/procon_bypass_man/procon/mode_registry.rb +4 -4
  46. data/lib/procon_bypass_man/procon/press_button_aware.rb +9 -7
  47. data/lib/procon_bypass_man/procon/user_operation.rb +46 -63
  48. data/lib/procon_bypass_man/procon/{analog_stick.rb → value_objects/analog_stick.rb} +3 -4
  49. data/lib/procon_bypass_man/procon/value_objects/procon_reader.rb +34 -0
  50. data/lib/procon_bypass_man/procon.rb +18 -16
  51. data/lib/procon_bypass_man/remote_pbm_action/change_pbm_version_action.rb +4 -0
  52. data/lib/procon_bypass_man/remote_pbm_action/{lib → commands}/update_remote_pbm_action_status_command.rb +0 -0
  53. data/lib/procon_bypass_man/remote_pbm_action/reboot_os_action.rb +4 -0
  54. data/lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb +28 -0
  55. data/lib/procon_bypass_man/remote_pbm_action/stop_pbm_action.rb +4 -0
  56. data/lib/procon_bypass_man/{value_objects → remote_pbm_action/value_objects}/remote_pbm_action_object.rb +0 -0
  57. data/lib/procon_bypass_man/remote_pbm_action.rb +3 -2
  58. data/lib/procon_bypass_man/runner.rb +4 -4
  59. data/lib/procon_bypass_man/scheduler.rb +0 -7
  60. data/lib/procon_bypass_man/support/compress_array.rb +5 -0
  61. data/lib/procon_bypass_man/support/http_client.rb +4 -0
  62. data/lib/procon_bypass_man/support/on_memory_cache.rb +3 -1
  63. data/lib/procon_bypass_man/support/report_http_client.rb +3 -3
  64. data/lib/procon_bypass_man/support/server_pool.rb +4 -0
  65. data/lib/procon_bypass_man/version.rb +1 -1
  66. data/lib/procon_bypass_man/websocket/pbm_job_client.rb +90 -0
  67. data/lib/procon_bypass_man.rb +50 -33
  68. data/procon_bypass_man.gemspec +2 -0
  69. data/project_template/README.md +10 -5
  70. data/project_template/app.rb +1 -1
  71. data/project_template/setting.yml +8 -8
  72. data/sig/main.rbs +226 -41
  73. data/sig/on_memory_cache.rbs +16 -0
  74. metadata +59 -20
  75. data/lib/procon_bypass_man/background/jobs/fetch_and_run_remote_pbm_action_job.rb +0 -29
  76. data/lib/procon_bypass_man/boot_message.rb +0 -48
  77. data/lib/procon_bypass_man/commands/run_local_shell_command.rb +0 -6
  78. data/lib/procon_bypass_man/procon_reader.rb +0 -31
  79. data/lib/procon_bypass_man/splatoon2/macro/fast_return.rb +0 -15
  80. data/lib/procon_bypass_man/splatoon2/macro/jump_to_left_key.rb +0 -15
  81. data/lib/procon_bypass_man/splatoon2/macro/jump_to_right_key.rb +0 -15
  82. data/lib/procon_bypass_man/splatoon2/macro/jump_to_up_key.rb +0 -15
  83. data/lib/procon_bypass_man/splatoon2/mode/guruguru.rb +0 -57
  84. data/lib/procon_bypass_man/splatoon2/version.rb +0 -7
  85. data/lib/procon_bypass_man/splatoon2.rb +0 -11
@@ -4,6 +4,9 @@ require "json"
4
4
  require "net/http"
5
5
  require "fileutils"
6
6
  require "securerandom"
7
+ require 'em/pure_ruby'
8
+ require "action_cable_client"
9
+ require "ext/em_pure_ruby"
7
10
 
8
11
  require_relative "procon_bypass_man/version"
9
12
  require_relative "procon_bypass_man/remote_pbm_action"
@@ -21,6 +24,7 @@ require_relative "procon_bypass_man/support/server_pool"
21
24
  require_relative "procon_bypass_man/background"
22
25
  require_relative "procon_bypass_man/commands"
23
26
  require_relative "procon_bypass_man/bypass"
27
+ require_relative "procon_bypass_man/domains"
24
28
  require_relative "procon_bypass_man/device_connector"
25
29
  require_relative "procon_bypass_man/device_status"
26
30
  require_relative "procon_bypass_man/runner"
@@ -28,49 +32,50 @@ require_relative "procon_bypass_man/processor"
28
32
  require_relative "procon_bypass_man/configuration"
29
33
  require_relative "procon_bypass_man/buttons_setting_configuration"
30
34
  require_relative "procon_bypass_man/procon"
31
- require_relative "procon_bypass_man/procon_reader"
32
- require_relative "procon_bypass_man/procon/analog_stick"
35
+ require_relative "procon_bypass_man/procon/button"
36
+ require_relative "procon_bypass_man/procon/value_objects/analog_stick"
37
+ require_relative "procon_bypass_man/procon/value_objects/procon_reader"
33
38
  require_relative "procon_bypass_man/procon/analog_stick_cap"
34
- require_relative "procon_bypass_man/value_objects/remote_pbm_action_object"
39
+ require_relative "procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object"
35
40
  require_relative "procon_bypass_man/scheduler"
36
- require_relative "procon_bypass_man/splatoon2"
41
+ require_relative "procon_bypass_man/plugins"
42
+ require_relative "procon_bypass_man/websocket/pbm_job_client"
37
43
 
38
44
  STDOUT.sync = true
39
45
  Thread.abort_on_exception = true
40
46
 
47
+ # pluginの定数を握りつぶす
48
+ class Module
49
+ def const_missing(id)
50
+ if self.name =~ /^ProconBypassMan::Plugin/
51
+ parent_const = Object.const_get("#{self.name}")
52
+ parent_const.const_set(id, Module.new)
53
+ Object.const_get("#{self.name}::#{id}")
54
+ else
55
+ super
56
+ end
57
+ end
58
+ end
59
+
41
60
  module ProconBypassMan
42
61
  extend ProconBypassMan::Configuration::ClassMethods
43
62
 
44
63
  class CouldNotLoadConfigError < StandardError; end
45
- class FirstConnectionError < StandardError; end
46
64
  class NotFoundProconError < StandardError; end
47
- class EternalConnectionError < StandardError; end
48
-
49
- def self.buttons_setting_configure(setting_path: nil, &block)
50
- unless setting_path
51
- logger.warn "setting_pathが未設定です。設定ファイルのライブリロードが使えません。"
52
- end
53
-
54
- if block_given?
55
- ProconBypassMan::ButtonsSettingConfiguration.instance.instance_eval(&block)
56
- else
57
- ProconBypassMan::ButtonsSettingConfiguration::Loader.load(setting_path: setting_path)
58
- end
59
- end
65
+ class ConnectionError < StandardError; end
66
+ class FirstConnectionError < ConnectionError; end
67
+ class EternalConnectionError < ConnectionError; end
60
68
 
61
69
  # @return [void]
62
- def self.run(setting_path: nil, &block)
70
+ def self.run(setting_path: nil)
63
71
  ProconBypassMan::Scheduler.start!
64
72
  ProconBypassMan::Background::JobRunner.start!
73
+ ProconBypassMan::Websocket::PbmJobClient.start!
65
74
 
66
- ProconBypassMan.logger.info "PBMを起動しています"
67
- puts "PBMを起動しています"
68
- buttons_setting_configure(setting_path: setting_path, &block)
75
+ ProconBypassMan::PrintMessageCommand.execute(text: "PBMを起動しています")
76
+ ProconBypassMan::ButtonsSettingConfiguration::Loader.load(setting_path: setting_path)
69
77
  initialize_pbm
70
- File.write(pid_path, $$)
71
- ProconBypassMan::WriteSessionIdCommand.execute
72
78
  gadget, procon = ProconBypassMan::ConnectDeviceCommand.execute!
73
- ProconBypassMan::DeviceStatus.change_to_running!
74
79
  Runner.new(gadget: gadget, procon: procon).run
75
80
  rescue ProconBypassMan::CouldNotLoadConfigError
76
81
  ProconBypassMan::SendErrorCommand.execute(error: "設定ファイルが不正です。設定ファイルの読み込みに失敗しました")
@@ -84,14 +89,18 @@ module ProconBypassMan
84
89
  FileUtils.rm_rf(ProconBypassMan.pid_path)
85
90
  FileUtils.rm_rf(ProconBypassMan.digest_path)
86
91
  exit 1
87
- rescue ProconBypassMan::EternalConnectionError
88
- ProconBypassMan::SendErrorCommand.execute(error: "接続の見込みがないのでsleepしまくります")
89
- ProconBypassMan::DeviceStatus.change_to_connected_but_sleeping!
90
- FileUtils.rm_rf(ProconBypassMan.pid_path)
91
- eternal_sleep
92
- rescue ProconBypassMan::FirstConnectionError
93
- ProconBypassMan::SendErrorCommand.execute(error: "接続を確立できませんでした。やりなおします。")
94
- retry
92
+ rescue ProconBypassMan::ConnectionError
93
+ begin
94
+ raise
95
+ rescue ProconBypassMan::EternalConnectionError
96
+ ProconBypassMan::SendErrorCommand.execute(error: "接続の見込みがないのでsleepしまくります")
97
+ ProconBypassMan::DeviceStatus.change_to_connected_but_sleeping!
98
+ FileUtils.rm_rf(ProconBypassMan.pid_path)
99
+ eternal_sleep
100
+ rescue ProconBypassMan::FirstConnectionError
101
+ ProconBypassMan::SendErrorCommand.execute(error: "接続を確立できませんでした。やりなおします。")
102
+ retry
103
+ end
95
104
  end
96
105
 
97
106
  def self.configure(&block)
@@ -116,9 +125,17 @@ module ProconBypassMan
116
125
 
117
126
  def self.initialize_pbm
118
127
  ProconBypassMan::WriteDeviceIdCommand.execute
128
+ ProconBypassMan::WriteSessionIdCommand.execute
129
+ File.write(pid_path, $$)
130
+ ProconBypassMan::DeviceStatus.change_to_running!
119
131
  end
120
132
 
121
133
  def self.eternal_sleep
122
134
  sleep(999999999)
123
135
  end
136
+
137
+ # @return [Void]
138
+ def self.hot_reload!
139
+ Process.kill(:USR2, pid)
140
+ end
124
141
  end
@@ -29,6 +29,8 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  # Uncomment to register a new dependency of your gem
31
31
  spec.add_dependency "pbmenv"
32
+ spec.add_dependency "action_cable_client"
33
+ spec.add_dependency "sorted_set"
32
34
 
33
35
  # For more information and examples about making a new gem, checkout our
34
36
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -1,11 +1,16 @@
1
1
  # Project Template
2
- これらは https://github.com/splaplapla/pbmenv がinstallするときに配備するファイルです
2
+ * これらは https://github.com/splaplapla/pbmenv がinstallするときに配備するファイルです
3
+ * pbm_webはオプショナルです
3
4
 
4
5
  ## systemdを使ってサービスに登録する方法
5
- * sudo ln -s /usr/share/pbm/current/systemd_units/pbm.service /etc/systemd/system/pbm.service
6
- * sudo ln -s /usr/share/pbm/current/systemd_units/pbm_web.service /etc/systemd/system/pbm_web.service
7
- * sudo systemctl enable pbm.service
8
- * sudo systemctl enable pbm_web.service
6
+ systemctl enableした後は、次回のOS起動時にserviceも自動起動します
7
+
8
+ * pbm
9
+ * sudo systemctl link /usr/share/pbm/current/systemd_units/pbm.service
10
+ * sudo systemctl enable pbm.service
11
+ * pbm_web
12
+ * sudo systemctl link /usr/share/pbm/current/systemd_units/pbm_web.service
13
+ * sudo systemctl enable pbm_web.service
9
14
 
10
15
  ## systemdを使ってサービスから解除する方法
11
16
  * sudo systemctl disable pbm.service
@@ -5,7 +5,7 @@ require 'bundler/inline'
5
5
  gemfile do
6
6
  source 'https://rubygems.org'
7
7
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
8
- gem 'procon_bypass_man', '0.1.14'
8
+ gem 'procon_bypass_man', '0.1.17'
9
9
  end
10
10
 
11
11
  ProconBypassMan.configure do |config|
@@ -1,12 +1,12 @@
1
1
  version: 1.0
2
2
  setting: |-
3
- fast_return = ProconBypassMan::Splatoon2::Macro::FastReturn
4
- guruguru = ProconBypassMan::Splatoon2::Mode::Guruguru
3
+ fast_return = ProconBypassMan::Plugin::Splatoon2::Macro::FastReturn
4
+ guruguru = ProconBypassMan::Plugin::Splatoon2::Mode::Guruguru
5
5
 
6
6
  install_macro_plugin fast_return
7
- install_macro_plugin ProconBypassMan::Splatoon2::Macro::JumpToUpKey
8
- install_macro_plugin ProconBypassMan::Splatoon2::Macro::JumpToRightKey
9
- install_macro_plugin ProconBypassMan::Splatoon2::Macro::JumpToLeftKey
7
+ install_macro_plugin ProconBypassMan::Plugin::Splatoon2::Macro::JumpToUpKey
8
+ install_macro_plugin ProconBypassMan::Plugin::Splatoon2::Macro::JumpToRightKey
9
+ install_macro_plugin ProconBypassMan::Plugin::Splatoon2::Macro::JumpToLeftKey
10
10
  install_mode_plugin guruguru
11
11
 
12
12
  prefix_keys_for_changing_layer [:zr, :zl, :l]
@@ -18,9 +18,9 @@ setting: |-
18
18
  flip :a, if_pressed: [:a]
19
19
  flip :down, if_pressed: :down
20
20
  macro fast_return.name, if_pressed: [:y, :b, :down]
21
- macro ProconBypassMan::Splatoon2::Macro::JumpToUpKey, if_pressed: [:y, :b, :up]
22
- macro ProconBypassMan::Splatoon2::Macro::JumpToRightKey, if_pressed: [:y, :b, :right]
23
- macro ProconBypassMan::Splatoon2::Macro::JumpToLeftKey, if_pressed: [:y, :b, :left]
21
+ macro ProconBypassMan::Plugin::Splatoon2::Macro::JumpToUpKey, if_pressed: [:y, :b, :up]
22
+ macro ProconBypassMan::Plugin::Splatoon2::Macro::JumpToRightKey, if_pressed: [:y, :b, :right]
23
+ macro ProconBypassMan::Plugin::Splatoon2::Macro::JumpToLeftKey, if_pressed: [:y, :b, :left]
24
24
  remap :l, to: :zr
25
25
  end
26
26
  layer :right, mode: guruguru.name
data/sig/main.rbs CHANGED
@@ -34,7 +34,13 @@ module ProconBypassMan
34
34
 
35
35
  def self.root=: (untyped path) -> untyped
36
36
 
37
+ def self.pid: () -> Integer
38
+
37
39
  def self.digest_path: () -> ::String
40
+
41
+ def self.session_id: () -> ::String
42
+
43
+ def self.device_id: () -> ::String
38
44
  end
39
45
 
40
46
  class ProconBypassMan::Bypass
@@ -166,42 +172,60 @@ end
166
172
 
167
173
  class ProconBypassMan::Configuration
168
174
  module ClassMethods
169
- def root: () -> untyped
175
+ def root: () -> String
170
176
 
171
- def logger: () -> untyped
177
+ def logger: () -> Logger
172
178
 
173
179
  def error_logger: () -> untyped
174
180
 
175
- def pid_path: () -> untyped
181
+ def pid_path: () -> String
176
182
 
177
- def digest_path: () -> untyped
183
+ def digest_path: () -> String
178
184
 
179
- def cache: () -> untyped
185
+ def cache: () -> ProconBypassMan::OnMemoryCache
180
186
 
181
- def config: () -> untyped
187
+ def config: () -> ProconBypassMan::Configuration
182
188
  end
183
189
 
184
190
  attr_reader api_server: untyped
185
191
  attr_reader api_servers: untyped
186
192
 
187
- attr_accessor enable_critical_error_logging: untyped
193
+ attr_accessor enable_critical_error_logging: bool
188
194
 
189
- def root=: (untyped path) -> untyped
195
+ def root=: (String path) -> ProconBypassMan::Configuration
190
196
 
191
- def root: () -> untyped
197
+ def root: () -> String
192
198
 
193
199
  def api_server=: (untyped api_server) -> untyped
194
200
 
195
- def logger=: (untyped logger) -> untyped
201
+ def logger=: (Logger logger) -> ProconBypassMan::Configuration
196
202
 
197
- def logger: () -> untyped
203
+ def logger: () -> Logger
198
204
 
199
- def error_logger: () -> untyped
205
+ def error_logger: () -> Logger
200
206
 
201
- def digest_path: () -> ::String
207
+ def digest_path: () -> String
202
208
 
203
209
  # @return [String] pbm-webの接続先
204
- def internal_api_servers: () -> untyped
210
+ def current_server: () -> String
211
+
212
+ def current_ws_server: () -> (String | nil)
213
+
214
+ def current_ws_server_url: () -> ::String
215
+
216
+ def enable_ws?: () -> bool
217
+
218
+ def server_pool: () -> untyped
219
+
220
+ def internal_server_pool: () -> untyped
221
+
222
+ def internal_servers: () -> ::Array[string | nil]
223
+
224
+ def internal_api_servers: () -> ::Array[untyped]
225
+
226
+ def raw_setting: () -> untyped
227
+
228
+ def verbose_bypass_log: () -> bool
205
229
  end
206
230
 
207
231
 
@@ -373,41 +397,41 @@ end
373
397
 
374
398
  class ProconBypassMan::Procon::MacroRegistry
375
399
  class Macro
376
- attr_accessor name: untyped
400
+ attr_accessor name: Symbol
377
401
 
378
402
  attr_accessor steps: untyped
379
403
 
380
- def initialize: (name: untyped name, steps: untyped steps) -> untyped
404
+ def initialize: (name: untyped Symbol, steps: Symbol) -> void
381
405
 
382
- def next_step: () -> untyped
406
+ def next_step: () -> Symbol
383
407
 
384
- def finished?: () -> untyped
408
+ def finished?: () -> bool
385
409
 
386
- def ongoing?: () -> untyped
410
+ def ongoing?: () -> bool
387
411
  end
388
412
 
389
- PRESETS: ::Hash[untyped, untyped]
413
+ PRESETS: ::Hash[Symbol, Array[Symbol]]
390
414
 
391
415
  def self.install_plugin: (untyped klass) -> untyped
392
416
 
393
- def self.load: (untyped name) -> untyped
417
+ def self.load: (Symbol name) -> untyped
394
418
 
395
- def self.reset!: () -> untyped
419
+ def self.reset!: () -> void
396
420
 
397
- def self.plugins: () -> untyped
421
+ def self.plugins: () -> ::Hash[Symbol, Array[Symbol]]
398
422
  end
399
423
 
400
424
  class ProconBypassMan::Procon::ModeRegistry
401
425
  class Mode
402
- attr_accessor name: untyped
426
+ attr_accessor name: Symbol
403
427
 
404
- attr_accessor binaries: untyped
428
+ attr_accessor binaries: Array[String]
405
429
 
406
- attr_accessor source_binaries: untyped
430
+ attr_accessor source_binaries: Array[String]
407
431
 
408
- def initialize: (name: untyped name, binaries: untyped binaries) -> untyped
432
+ def initialize: (name: Symbol, binaries: Array[String]) -> void
409
433
 
410
- def next_binary: () -> untyped
434
+ def next_binary: () -> String
411
435
  end
412
436
 
413
437
  PRESETS: ::Hash[untyped, untyped]
@@ -421,30 +445,20 @@ class ProconBypassMan::Procon::ModeRegistry
421
445
  def self.plugins: () -> untyped
422
446
  end
423
447
 
424
- module ProconBypassMan::Procon::PressedButtonHelper
425
- module Static
426
- def pressed_button?: (untyped button) -> untyped
427
- end
428
- end
429
-
430
448
  class ProconBypassMan::Procon
431
449
  class UserOperation
432
450
  include LayerChangeable
433
451
 
434
- include PressedButtonHelper::Static
435
-
436
452
  attr_reader binary: untyped
437
453
 
438
454
  def initialize: (untyped binary) -> untyped
439
455
 
440
- ZERO_BIT: untyped
441
-
442
456
  ASCII_ENCODING: ::String
443
457
 
444
458
  # @depilicate
445
459
  def binary=: (untyped binary) -> untyped
446
460
 
447
- def set_no_action!: () -> untyped
461
+ def set_no_action!: () -> void
448
462
 
449
463
  def unpress_button: (untyped button) -> untyped
450
464
 
@@ -482,7 +496,7 @@ module ProconBypassMan
482
496
  end
483
497
 
484
498
  # 5秒後がタイムアウト
485
- def initialize: (?timeout: untyped timeout) -> untyped
499
+ def initialize: (?timeout: untyped timeout) -> void
486
500
 
487
501
  def throw_if_timeout!: () -> untyped
488
502
  end
@@ -494,7 +508,7 @@ module ProconBypassMan
494
508
  def self.from_boot: () -> Integer
495
509
 
496
510
  # @param [String] uptime_cmd_result
497
- def initialize: (uptime_cmd_result: String uptime_cmd_result) -> void
511
+ def initialize: (uptime_cmd_result: String) -> void
498
512
 
499
513
  # @return [Integer]
500
514
  def from_boot: () -> Integer
@@ -504,3 +518,174 @@ end
504
518
  module ProconBypassMan
505
519
  VERSION: ::String
506
520
  end
521
+
522
+ module ProconBypassMan
523
+ module Domains
524
+ module Binary
525
+ end
526
+ end
527
+ end
528
+
529
+ class ProconBypassMan::Domains::Binary::Base
530
+ # @param [String] binary
531
+ def initialize: (binary: untyped binary) -> void
532
+
533
+ # @return [String] バイナリ
534
+ def binary: () -> untyped
535
+
536
+ # @return [String]
537
+ def raw: () -> ::String
538
+
539
+ def unpack: () -> Array[::String]
540
+
541
+ # @return [ProconBypassMan::ProconReader]
542
+ def to_procon_reader: () -> untyped
543
+ end
544
+
545
+ module ProconBypassMan::Domains::HasImmutableBinary
546
+ def binary: () -> untyped
547
+ end
548
+
549
+ module ProconBypassMan::Domains::HasMutableBinary
550
+ def binary: () -> untyped
551
+ end
552
+
553
+ class ProconBypassMan::Domains::InboundProconBinary < ProconBypassMan::Domains::Binary::Base
554
+ include ProconBypassMan::Domains::HasImmutableBinary
555
+
556
+ # @return [Boolean]
557
+ def user_operation_data?: () -> bool
558
+ end
559
+
560
+ # バイナリの書き換えのみをする
561
+ class ProconBypassMan::Domains::ProcessingProconBinary < ProconBypassMan::Domains::Binary::Base
562
+ include ProconBypassMan::Domains::HasMutableBinary
563
+
564
+ ALL_ZERO_BIT: ::String
565
+
566
+ def set_no_action!: () -> untyped
567
+
568
+ # @param [ProconBypassMan::Domains::ProcessingProconBinary]
569
+ # @return [ProconBypassMan::Domains::ProcessingProconBinary]
570
+ # アナログスティックは上書きし、ボタンだけマージする
571
+ def write_as_merge!: (untyped target_binary) -> ProconBypassMan::Domains::ProcessingProconBinary
572
+
573
+ # @param [Symbol] button
574
+ def write_as_press_button: (Symbol button) -> void
575
+
576
+ # @param [Symbol] button
577
+ def write_as_unpress_button: (Symbol button) -> void
578
+
579
+ # @param [Symbol] button
580
+ def write_as_press_button_only: (Symbol button) -> void
581
+
582
+ # @param [Integer] cap
583
+ def write_as_apply_left_analog_stick_cap: (cap: Integer cap) -> void
584
+ end
585
+
586
+ module ProconBypassMan
587
+ class HttpClient
588
+ @server_pool: untyped
589
+ @uri: ::URI
590
+ @retry_on_connection_error: false
591
+
592
+ def initialize: (path: String, server_pool: untyped, ?retry_on_connection_error: false) -> void
593
+ def get: -> nil
594
+ def post: (request_body: untyped) -> nil
595
+ def put: (request_body: untyped) -> nil
596
+
597
+ private
598
+ def process_response: (untyped response) -> untyped
599
+ def handle_request: { -> bot } -> nil
600
+
601
+ class HttpRequest
602
+ class Get
603
+ def self.request!: (uri: ::URI) -> untyped
604
+ end
605
+
606
+ class Post
607
+ def self.request!: (uri: ::URI, ?request_body: Hash[untyped, untyped]) -> untyped
608
+ end
609
+
610
+ class Put
611
+ def self.request!: (uri: ::URI, ?request_body: {hostname: String}) -> untyped
612
+ end
613
+ end
614
+ end
615
+ end
616
+
617
+ module ProconBypassMan
618
+ class SendDeviceStatsHttpClient
619
+ def post: (status: ::Symbol, pbm_session_id: String) -> untyped
620
+ end
621
+ end
622
+
623
+ module ProconBypassMan
624
+ class ReportHttpClient
625
+ def post: (body: Hash[untyped, untyped] | String, event_type: ::Symbol) -> untyped
626
+ end
627
+ end
628
+
629
+ module ProconBypassMan
630
+ class UpdateRemotePbmActionStatusHttpClient
631
+ def post: (to_status: ::Symbol) -> untyped
632
+ end
633
+ end
634
+
635
+ module ProconBypassMan
636
+ class ServerPool
637
+ @servers: Array[String]
638
+ @index: Integer?
639
+
640
+ def initialize: (servers: Array[String]) -> void
641
+ def pick: -> String?
642
+ def server: -> String?
643
+ def next!: -> nil
644
+
645
+ private
646
+ def reset: -> Integer
647
+ def inc_index: -> Integer
648
+ end
649
+ end
650
+
651
+ module ProconBypassMan
652
+ class CompressArray
653
+ @array: [String]
654
+
655
+ def initialize: ([String] array) -> void
656
+ def compress: -> Array[String?]
657
+
658
+ class CompressibleValue
659
+ @prev: String?
660
+ @current: String
661
+
662
+ def initialize: (String? prev, String current) -> void
663
+ def compress?: -> bool
664
+ def to_s_with_mark: -> String?
665
+ end
666
+ end
667
+ end
668
+
669
+ module ProconBypassMan
670
+ module Callbacks
671
+ def run_callbacks: (untyped kind) -> untyped
672
+ def get_callbacks: (untyped kind) -> untyped
673
+ def set_callbacks: (untyped name, untyped callbacks) -> untyped
674
+
675
+ class CallbacksChain
676
+ @block: nil
677
+
678
+ attr_accessor filter: untyped
679
+ attr_accessor chain_method: untyped
680
+ def initialize: (filter: untyped, chain_method: untyped, block: nil) -> void
681
+ end
682
+
683
+ module M
684
+ end
685
+
686
+ module ClassMethods
687
+ def define_callbacks: (untyped name) -> untyped
688
+ def set_callback: (untyped kind, untyped filter, untyped chain_method) -> CallbacksChain
689
+ end
690
+ end
691
+ end
@@ -0,0 +1,16 @@
1
+ class ProconBypassMan::OnMemoryCache
2
+ class CacheValue
3
+ # @param [Time]
4
+ attr_accessor expired_at: Time
5
+
6
+ attr_accessor value: untyped
7
+
8
+ def initialize: (expired_at: Time, value: untyped) -> void
9
+ end
10
+
11
+ def initialize: () -> void
12
+
13
+ # @param [Integer] expires_in 秒数
14
+ # @param [String] key
15
+ def fetch: (key: string, expires_in: Time) { () -> untyped } -> untyped
16
+ end