Sha256: 1818aceb782a1050e5ac14291e48dcc2e92b09b91fb4873617ed982a704eb226

Contents?: true

Size: 1.03 KB

Versions: 5

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

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

require "pakyow/realtime/server"

module Pakyow
  module Realtime
    module Behavior
      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
              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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pakyow-realtime-1.0.0.rc5 lib/pakyow/realtime/behavior/server.rb
pakyow-realtime-1.0.0.rc4 lib/pakyow/realtime/behavior/server.rb
pakyow-realtime-1.0.0.rc3 lib/pakyow/realtime/behavior/server.rb
pakyow-realtime-1.0.0.rc2 lib/pakyow/realtime/behavior/server.rb
pakyow-realtime-1.0.0.rc1 lib/pakyow/realtime/behavior/server.rb