Class: Onebot::WebSocket::Server
- Defined in:
- lib/Core/WebSocket/Server.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#ws ⇒ Faye::WebSocket
Ws server.
Attributes inherited from Bot
Instance Method Summary collapse
-
#initialize(env:, logger: nil, options: { ping: 5 }) {|_self| ... } ⇒ Server
constructor
A new instance of Server.
- #rack_response ⇒ Object
Methods inherited from Bot
#method_missing, #respond_to_missing?, #sendMessage
Constructor Details
#initialize(env:, logger: nil, options: { ping: 5 }) {|_self| ... } ⇒ Server
Returns a new instance of Server.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/Core/WebSocket/Server.rb', line 11 def initialize(env:, logger: nil, options: { ping: 5 }, &block) super @eventLogger = Logging::EventLogger.new(logger) @ws = Faye::WebSocket.new(env, %w[irc xmpp], ) @api = API.new(@ws, @eventLogger) @eventLogger.log(['客户端', '连接', @ws.url, @ws.version], ::Logger::INFO, 'Server') @ws.on :message do |event| Thread.new { dataParse(event.data) } end @ws.on :close do |event| @eventLogger.log(['客户端', '断开', event.code].to_s, ::Logger::INFO, 'Server') @ws = nil end yield self if block_given? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Onebot::WebSocket::Bot
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
7 8 9 |
# File 'lib/Core/WebSocket/Server.rb', line 7 def api @api end |
#ws ⇒ Faye::WebSocket
Returns ws server.
6 7 8 |
# File 'lib/Core/WebSocket/Server.rb', line 6 def ws @ws end |
Instance Method Details
#rack_response ⇒ Object
30 31 32 |
# File 'lib/Core/WebSocket/Server.rb', line 30 def rack_response @ws.rack_response end |