Class: Mongrel2::WebSocket::Response
Overview
WebSocket response – this is the container for Frames sent to a client.
Constant Summary
Constants inherited from Response
Instance Attribute Summary
Attributes inherited from Response
#body, #chunksize, #conn_id, #extended_reply_data, #extended_reply_filter, #request, #sender_id
Class Method Summary collapse
-
.from_request(request) ⇒ Object
Return a response to the specified
request
, inferring appropriate flags if appropriate.
Instance Method Summary collapse
-
#frame ⇒ Object
Delegate some methods to the contained frame.
-
#initialize(sender_id, conn_id, body = '') ⇒ Response
constructor
Init a few instance variables unique to websocket requests/responses.
Methods included from FrameMethods
Methods inherited from Response
#<<, #each_chunk, #extend_reply_with, #extended_reply?, #inspect, #puts, #socket_id, #to_s
Constructor Details
#initialize(sender_id, conn_id, body = '') ⇒ Response
Init a few instance variables unique to websocket requests/responses.
402 403 404 405 |
# File 'lib/mongrel2/websocket.rb', line 402 def initialize( sender_id, conn_id, body='' ) @frame = Mongrel2::WebSocket::Frame.new( body ) super( sender_id, conn_id, @frame.payload ) end |
Class Method Details
.from_request(request) ⇒ Object
Return a response to the specified request
, inferring appropriate flags if appropriate.
386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/mongrel2/websocket.rb', line 386 def self::from_request( request ) response = super if request.opcode == :ping response.opcode = :pong IO.copy_stream( request.payload, response.payload, 4096 ) else # Numeric in case it's a custom (reserved) value response.opcode = request.numeric_opcode end return response end |
Instance Method Details
#frame ⇒ Object
Delegate some methods to the contained frame
410 411 |
# File 'lib/mongrel2/websocket.rb', line 410 def_instance_delegators :frame, :puts, :to_s, :each_chunk, :<<, :make_close_frame, :set_status |