310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
# File 'lib/tipi/digital_fabric/agent_proxy.rb', line 310
def run_websocket_connection(id, websocket)
reader = spin("#{Fiber.current}.#{id}-ws") do
websocket.recv_loop do |data|
send_df_message(Protocol.ws_data(id, data))
end
end
while (message = receive)
case message[Protocol::Attribute::KIND]
when Protocol::WS_DATA
websocket << message[Protocol::Attribute::WS::DATA]
when Protocol::WS_CLOSE
return
else
raise "Unexpected websocket message #{message.inspect}"
end
end
ensure
reader.stop
websocket.close
end
|