Class: Spikard::WebSocketHandler
- Inherits:
-
Object
- Object
- Spikard::WebSocketHandler
- Defined in:
- lib/spikard/websocket.rb
Overview
Base class for WebSocket message handlers.
Implement this class to handle WebSocket connections and messages.
Instance Method Summary collapse
-
#handle_message(message) ⇒ Hash?
Handle an incoming WebSocket message.
-
#on_connect ⇒ void
Called when a client connects.
-
#on_disconnect ⇒ void
Called when a client disconnects.
Instance Method Details
#handle_message(message) ⇒ Hash?
Handle an incoming WebSocket message.
37 38 39 |
# File 'lib/spikard/websocket.rb', line 37 def () raise NotImplementedError, "#{self.class.name} must implement #handle_message" end |
#on_connect ⇒ void
This method returns an undefined value.
Called when a client connects.
Override this method to perform initialization when a client connects.
46 47 48 |
# File 'lib/spikard/websocket.rb', line 46 def on_connect # Optional hook - default implementation does nothing end |
#on_disconnect ⇒ void
This method returns an undefined value.
Called when a client disconnects.
Override this method to perform cleanup when a client disconnects.
55 56 57 |
# File 'lib/spikard/websocket.rb', line 55 def on_disconnect # Optional hook - default implementation does nothing end |