Class: WebSocketRb::Context::Sandbox
- Inherits:
-
Object
- Object
- WebSocketRb::Context::Sandbox
- Defined in:
- lib/web_socket_rb/context/sandbox.rb
Instance Method Summary collapse
-
#broadcast_message(destination, message) ⇒ Object
Method to broadcast message to all clients.
-
#connections_size ⇒ Object
Method to get count of current connections.
-
#initialize(frames_sender) ⇒ Sandbox
constructor
A new instance of Sandbox.
-
#send_message(destination, message) ⇒ Object
Method to send message to client.
Constructor Details
#initialize(frames_sender) ⇒ Sandbox
Returns a new instance of Sandbox.
7 8 9 |
# File 'lib/web_socket_rb/context/sandbox.rb', line 7 def initialize(frames_sender) @frames_sender = frames_sender end |
Instance Method Details
#broadcast_message(destination, message) ⇒ Object
Method to broadcast message to all clients
23 24 25 26 |
# File 'lib/web_socket_rb/context/sandbox.rb', line 23 def (destination, ) frame = Service::BuildTextFrameService.new(destination, ).run @frames_sender.frame_to_broadcast(frame) end |
#connections_size ⇒ Object
Method to get count of current connections
12 13 14 |
# File 'lib/web_socket_rb/context/sandbox.rb', line 12 def connections_size @frames_sender.connections.size end |
#send_message(destination, message) ⇒ Object
Method to send message to client
17 18 19 20 |
# File 'lib/web_socket_rb/context/sandbox.rb', line 17 def (destination, ) frame = Service::BuildTextFrameService.new(destination, ).run @frames_sender.frame_to_send(frame) end |