This class encapsulates all the low-level logic of working with the underlying WebSocket connections and delegate all the business-logic to the user-level connection object (e.g., ApplicationCable::Connection). This connection object is also responsible for handling encoding and decoding of messages, so the user-level connection object shouldn’t know about such details.
- C
- N
- P
- R
- S
- T
Attributes
| [R] | connection | |
| [R] | env | |
| [R] | logger | |
| [R] | protocol | |
| [R] | server |
Class Public methods
new(server, env, coder: ActiveSupport::JSON) Link
# File actioncable/lib/action_cable/server/socket.rb, line 19 def initialize(server, env, coder: ActiveSupport::JSON) @server, @env, @coder = server, env, coder @worker_pool = server.worker_pool # Runs this socket's work on the worker pool's threads, one job at a time, # in the order it was posted. @serial_executor = Concurrent::SerializedExecutionDelegator.new(worker_pool.executor) @logger = server.new_tagged_logger { request } @websocket = WebSocket.new(env, self, event_loop) @message_buffer = MessageBuffer.new(self) @protocol = nil @connection = config.connection_class.call.new(server, self) end
Instance Public methods
close(...) Link
Close the WebSocket connection.
perform_work(receiver, method, *args) Link
Invoke a method on the connection asynchronously through the pool of thread workers. Like the connection’s commands, these calls run one at a time, in the order they were made.
request() Link
The request that initiated the WebSocket connection is available here. This gives access to the environment, cookies, etc.
send_async(method, *arguments) Link
Invoke a method on this socket through the pool of thread workers. These calls run one at a time, in the order they were made, so a client’s commands are handled in the order it sent them.