Class: DripDrop::WebSocketHandler::Connection

Inherits:
BaseHandler
  • Object
show all
Defined in:
lib/dripdrop/handlers/websocket_server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseHandler

#handle_error, #on_error, #print_exception

Constructor Details

#initialize(ws) ⇒ Connection

Returns a new instance of Connection.



77
78
79
80
# File 'lib/dripdrop/handlers/websocket_server.rb', line 77

def initialize(ws)
  @ws = ws
  @signature = @ws.signature
end

Instance Attribute Details

#handlerObject (readonly)

Returns the value of attribute handler.



75
76
77
# File 'lib/dripdrop/handlers/websocket_server.rb', line 75

def handler
  @handler
end

#signatureObject (readonly)

Returns the value of attribute signature.



75
76
77
# File 'lib/dripdrop/handlers/websocket_server.rb', line 75

def signature
  @signature
end

#wsObject (readonly)

Returns the value of attribute ws.



75
76
77
# File 'lib/dripdrop/handlers/websocket_server.rb', line 75

def ws
  @ws
end

Instance Method Details

#send_message(message) ⇒ Object



82
83
84
85
86
87
88
89
# File 'lib/dripdrop/handlers/websocket_server.rb', line 82

def send_message(message)
  begin
    encoded_message = dd_messagify(message).encoded
    @ws.send(encoded_message)
  rescue StandardError => e
    handle_error(e)
  end
end