Sha256: 18a42d236ae5b9d419afe8a1886f04aeb3cd8a69e053564aaee519b45a3e19b9

Contents?: true

Size: 914 Bytes

Versions: 1

Compression:

Stored size: 914 Bytes

Contents

module PipeRpc
  class Server < BasicInterface
    TRANSPORT_PREFIX = "__rpc_server__"

    include Kernel.dup_including :object_id, class: :__class__
    private :__class__

    def __rpc_server_class_name__
      __class__.to_s
    end

    def __rpc_server_instance_id__
      __id__.to_s
    end

    def __rpc_server_id__
      @__rpc_server_id__ ||= [__rpc_server_class_name__, *__rpc_server_instance_id__].join('#').to_sym
    end

    def inspect
      __rpc_server_id__
    end
    alias to_s inspect

    def to_rpc_transport(gateway)
      gateway.servers.add(self) unless gateway.servers.registered? __rpc_server_id__
      "#{TRANSPORT_PREFIX}#{__rpc_server_id__}"
    end
  end

  class << Server
    def from_rpc_transport(gateway, transport)
      server = gateway.servers[transport.sub(Client::TRANSPORT_PREFIX, '').to_sym]
      SubjectServer.from_rpc_transport(gateway, server)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pipe_rpc-2.5.0 lib/pipe_rpc/server.rb