Class: Riddl::WebSocketImplementation

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby/riddl/implementation.rb

Direct Known Subclasses

Utils::Notifications::Producer::WS

Instance Method Summary collapse

Constructor Details

#initialize(ws) ⇒ WebSocketImplementation

Returns a new instance of WebSocketImplementation.



65
66
67
68
69
70
71
72
# File 'lib/ruby/riddl/implementation.rb', line 65

def initialize(ws)
  @ws    = ws
  @r     = ws[:r]     # the matching resource path
  @s     = ws[:s]     # the matching resource path schema
  @match = ws[:match] # the path of the branch matching, important for recursive
  @env   = ws[:env]   # environment (all headers)
  @a     = ws[:a]     # args to run command
end

Instance Method Details

#closeObject



93
94
95
# File 'lib/ruby/riddl/implementation.rb', line 93

def close
  @ws[:io].close_connection
end

#closed?Boolean

Returns:

  • (Boolean)


89
90
91
# File 'lib/ruby/riddl/implementation.rb', line 89

def closed?
  @ws[:io].closed?
end

#ioObject



86
87
88
# File 'lib/ruby/riddl/implementation.rb', line 86

def io
  @ws[:io]
end

#io=(connection) ⇒ Object



83
84
85
# File 'lib/ruby/riddl/implementation.rb', line 83

def io=(connection)
  @ws[:io] = connection
end

#oncloseObject



75
# File 'lib/ruby/riddl/implementation.rb', line 75

def onclose;end

#onerror(err) ⇒ Object



77
# File 'lib/ruby/riddl/implementation.rb', line 77

def onerror(err);end

#onmessageObject



76
# File 'lib/ruby/riddl/implementation.rb', line 76

def onmessage;end

#onopenObject



74
# File 'lib/ruby/riddl/implementation.rb', line 74

def onopen;end

#send(data) ⇒ Object



79
80
81
# File 'lib/ruby/riddl/implementation.rb', line 79

def send(data)
  @ws[:io].send data
end