Sha256: 29fd6628e1a78651af9c68d551cadbb2e39482e1b7648f1a9b8d33c2e68f3123

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

require "pakyow/support/deep_freeze"
require "pakyow/support/extension"

require "pakyow/realtime/server"

module Pakyow
  class Application
    module Behavior
      module Realtime
        module Server
          extend Support::Extension

          apply_extension do
            extend Support::DeepFreeze
            unfreezable :websocket_server
            attr_reader :websocket_server

            after "initialize", priority: :high do
              @websocket_server = if is_a?(Plugin)
                parent.websocket_server
              else
                Pakyow::Realtime::Server.new(
                  Pakyow.config.realtime.adapter,
                  Pakyow.config.realtime.adapter_settings.to_h.merge(
                    config.realtime.adapter_settings.to_h
                  ),
                  config.realtime.timeouts
                )
              end
            end

            on "shutdown" do
              if instance_variable_defined?(:@websocket_server)
                @websocket_server.shutdown
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
pakyow-realtime-1.0.6 lib/pakyow/application/behavior/realtime/server.rb
pakyow-realtime-1.0.5 lib/pakyow/application/behavior/realtime/server.rb
pakyow-realtime-1.0.4 lib/pakyow/application/behavior/realtime/server.rb
pakyow-realtime-1.0.3 lib/pakyow/application/behavior/realtime/server.rb
pakyow-realtime-1.0.2 lib/pakyow/application/behavior/realtime/server.rb
pakyow-realtime-1.0.1 lib/pakyow/application/behavior/realtime/server.rb
pakyow-realtime-1.0.0 lib/pakyow/application/behavior/realtime/server.rb