Class: AnyCable::RackServer::RPC::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/anycable/rack-server/rpc/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ Client

Returns a new instance of Client.



11
12
13
# File 'lib/anycable/rack-server/rpc/client.rb', line 11

def initialize(host)
  @stub = AnyCable::RPC::Service.rpc_stub_class.new(host, :this_channel_is_insecure)
end

Instance Attribute Details

#stubObject (readonly)

Returns the value of attribute stub.



9
10
11
# File 'lib/anycable/rack-server/rpc/client.rb', line 9

def stub
  @stub
end

Instance Method Details

#command(command:, identifier:, connection_identifiers:, data:) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/anycable/rack-server/rpc/client.rb', line 20

def command(command:, identifier:, connection_identifiers:, data:)
  message = CommandMessage.new(
    command: command,
    identifier: identifier,
    connection_identifiers: connection_identifiers,
    data: data
  )
  stub.command(message)
end

#connect(headers:, path:) ⇒ Object



15
16
17
18
# File 'lib/anycable/rack-server/rpc/client.rb', line 15

def connect(headers:, path:)
  request = ConnectionRequest.new(headers: headers, path: path)
  stub.connect(request)
end

#disconnect(identifiers:, subscriptions:, headers:, path:) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/anycable/rack-server/rpc/client.rb', line 30

def disconnect(identifiers:, subscriptions:, headers:, path:)
  request = DisconnectRequest.new(
    identifiers: identifiers,
    subscriptions: subscriptions,
    headers: headers,
    path: path
  )
  stub.disconnect(request)
end