Class: DRb::WebSocket::CallbackHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/drb/websocket.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ CallbackHandler

Returns a new instance of CallbackHandler.



50
51
52
53
# File 'lib/drb/websocket.rb', line 50

def initialize(uri)
  @uri = uri
  @queue = Thread::Queue.new
end

Instance Method Details

#on_message(data) ⇒ Object



55
56
57
58
59
# File 'lib/drb/websocket.rb', line 55

def on_message(data)
  sio = StrStream.new
  sio.write(data.pack('C*'))
  @queue.push sio
end

#on_session_start(ws) ⇒ Object



61
62
63
# File 'lib/drb/websocket.rb', line 61

def on_session_start(ws)
  @ws = ws
end

#send(url, data) ⇒ Object



69
70
71
# File 'lib/drb/websocket.rb', line 69

def send(url, data)
  @ws.send(data.bytes)
end

#streamObject



65
66
67
# File 'lib/drb/websocket.rb', line 65

def stream
  @queue.pop
end