ActionCable和外部websockets

时间:2018-06-13 08:04:37

标签: ruby-on-rails ruby websocket actioncable

我有我的websocket ruby​​服务器:

require 'em-websocket'
require "awesome_print"

ap "WebSocket server started"

EM.run {
 EM::WebSocket.run(:host => "0.0.0.0", :port => 8080) do |ws|
   ws.onopen { |handshake|
   puts "WebSocket connection open"

   # Publish message to the client
   ws.send "Client connected to #{handshake.path}"
 }

 ws.onclose { puts "Connection closed" }

 ws.onmessage { |msg|
   puts "Recieved message: #{msg}"
   ws.send "Pong: #{msg}"
 }
end
}

如何使用外部websockets消息连接我的rails app websockets? 当我得到正确的信息时,我想展示一些东西。

0 个答案:

没有答案