Class: Scarpe::Webview::ContainedService
- Inherits:
-
Shoes::Linkable
- Object
- Shoes::Linkable
- Scarpe::Webview::ContainedService
- Includes:
- Scarpe::WVRelayUtil, Shoes::Log
- Defined in:
- lib/scarpe/wv/wv_display_worker.rb
Overview
This is the implementation of a freestanding Scarpe Webview display server, which connects via sockets and sends events and properties back and forth with a display-less Shoes app. The interface is designed to allow fork-based usage, where a parent process could create a paired sockets and start the child server. It can also be used via TCP sockets or similar, where a single socket is both input and output.
Constant Summary
Constants included from Shoes::Log
Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG
Instance Attribute Summary collapse
-
#log ⇒ Object
readonly
Returns the value of attribute log.
Attributes inherited from Shoes::Linkable
Instance Method Summary collapse
-
#initialize(from, to) ⇒ ContainedService
constructor
Create a new DisplayService.
Methods included from Scarpe::WVRelayUtil
#event_loop_for, #ready_to_read?, #receive_datagram, #respond_to_datagram, #send_datagram
Methods included from Shoes::Log
configure_logger, #log_init, logger
Methods inherited from Shoes::Linkable
#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_all_shoes_events, #unsub_shoes_event
Constructor Details
#initialize(from, to) ⇒ ContainedService
Create a new DisplayService.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/scarpe/wv/wv_display_worker.rb', line 39 def initialize(from, to) super() log_init("Webview::DisplayWorker") @i_am = :child @event_subs = [] @wv_display = Scarpe::Webview::DisplayService.new @from = from @to = to @init_done = false # Wait to register our periodic_code until the wrangler exists @event_subs << bind_shoes_event(event_name: "init") do @wv_display.wrangler.periodic_code("datagramProcessor", 0.1) do respond_to_datagram while ready_to_read?(0.0) end @init_done = true end # Subscribe to all event notifications and relay them to the opposite side @event_subs << bind_shoes_event(event_name: :any, target: :any) do |*args, **kwargs| unless kwargs[:relayed] || kwargs["relayed"] kwargs[:relayed] = true send_datagram({ type: :event, args:, kwargs: }) end end # Run for 2.5 seconds to let the app be created and "run" to get called. # Once that happens, Webview will take over the event loop. event_loop_for(2.5) end |
Instance Attribute Details
#log ⇒ Object (readonly)
Returns the value of attribute log.
33 34 35 |
# File 'lib/scarpe/wv/wv_display_worker.rb', line 33 def log @log end |