Class: Anycable::RPCHandler
- Inherits:
-
Anycable::RPC::Service
- Object
- Anycable::RPC::Service
- Anycable::RPCHandler
- Includes:
- Handler::ExceptionsHandling
- Defined in:
- lib/anycable/rpc_handler.rb
Overview
RPC service handler
Instance Method Summary collapse
- #command(message, _unused_call) ⇒ Object
-
#connect(request, _unused_call) ⇒ Object
Handle connection request from WebSocket server.
- #disconnect(request, _unused_call) ⇒ Object
Methods included from Handler::ExceptionsHandling
Instance Method Details
#command(message, _unused_call) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/anycable/rpc_handler.rb', line 55 def command(, _unused_call) logger.debug("RPC Command: #{.inspect}") socket = build_socket connection = factory.call( socket, identifiers: .connection_identifiers ) result = connection.handle_channel_command( .identifier, .command, .data ) Anycable::CommandResponse.new( status: result ? Anycable::Status::SUCCESS : Anycable::Status::FAILURE, disconnect: socket.closed?, stop_streams: socket.stop_streams?, streams: socket.streams, transmissions: socket.transmissions ) end |
#connect(request, _unused_call) ⇒ Object
Handle connection request from WebSocket server
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/anycable/rpc_handler.rb', line 17 def connect(request, _unused_call) logger.debug("RPC Connect: #{request.inspect}") socket = build_socket(env: rack_env(request)) connection = factory.call(socket) connection.handle_open if socket.closed? Anycable::ConnectionResponse.new(status: Anycable::Status::FAILURE) else Anycable::ConnectionResponse.new( status: Anycable::Status::SUCCESS, identifiers: connection.identifiers_json, transmissions: socket.transmissions ) end end |
#disconnect(request, _unused_call) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/anycable/rpc_handler.rb', line 37 def disconnect(request, _unused_call) logger.debug("RPC Disconnect: #{request.inspect}") socket = build_socket(env: rack_env(request)) connection = factory.call( socket, identifiers: request.identifiers, subscriptions: request.subscriptions ) if connection.handle_close Anycable::DisconnectResponse.new(status: Anycable::Status::SUCCESS) else Anycable::DisconnectResponse.new(status: Anycable::Status::FAILURE) end end |