我有兩個websocket客戶端,我想在它們之間交換信息。em-websocket send()通過2臺服務器從一個客戶端發送到另一個客戶端
比方說,我有兩個套接字服務器實例,1st檢索私人信息,過濾它併發送到第二個。
require 'em-websocket'
EM.run do
EM::WebSocket.run(host: '0.0.0.0', port: 19108) do |manager_emulator|
# retrieve information. After that I need to send it to another port (9108)
end
EM::WebSocket.run(host: '0.0.0.0', port: 9108) do |fake_manager|
# I need to send filtered information here
end
end
我試過去做一些事情,但是我得到了一般的黑暗代碼,我不知道如何實現這個功能。
你爲什麼要在定義服務的過程中引發異常? ('raise manager_emulator.inspect') – Myst
omg,我用它來調試。我現在將它刪除 – asiniy