lib/reel/websocket.rb in reel-0.4.0.pre vs lib/reel/websocket.rb in reel-0.4.0.pre2

- old
+ new

@@ -5,14 +5,16 @@ class WebSocket extend Forwardable include ConnectionMixin include RequestMixin + attr_reader :socket def_delegators :@socket, :addr, :peeraddr - def initialize(http_parser, socket) - @http_parser, @socket = http_parser, socket + def initialize(info, socket) + @request_info = info + @socket = socket handshake = ::WebSocket::ClientHandshake.new(:get, url, headers) if handshake.valid? response = handshake.accept_response @@ -34,11 +36,11 @@ # close message before closing the connection @socket << ::WebSocket::Message.close.to_data close end - @parser.on_ping do - @socket << ::WebSocket::Message.pong.to_data + @parser.on_ping do |payload| + @socket << ::WebSocket::Message.pong(payload).to_data end end [:next_message, :next_messages, :on_message, :on_error, :on_close, :on_ping, :on_pong].each do |meth| define_method meth do |&proc|