Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Grab some methods from faye"

This reverts commit 71b6b40.
  • Loading branch information...
commit d48945dafdea711731bdc2d2646e40ce75b71f68 1 parent 71b6b40
Pratik lifo authored
Showing with 4 additions and 20 deletions.
  1. +4 −20 lib/cramp/websocket.rb
24 lib/cramp/websocket.rb
View
@@ -20,10 +20,7 @@ def on_data(*methods)
end
def process
- @buffer = []
- @buffering = false
- @env['websocket.receive_callback'] = lambda {|data| data.each_char(&method(:_on_data_receive)) }
-
+ @env['websocket.receive_callback'] = method(:_on_data_receive)
super
end
@@ -32,25 +29,12 @@ def render(body)
@body.call(data)
end
- # _on_data_receive/encode methods derived from Faye - https://github.com/jcoglan/faye
- #
- # Copyright (c) 2009-2010 James Coglan
- # The MIT License
def _on_data_receive(data)
- case data
- when "\x00" then
- @buffering = true
- when "\xFF" then
- message = encode(@buffer.join(''))
-
- self.class.on_data_callbacks.each do |callback|
+ data = data.split(/\000([^\377]*)\377/).select{|d| !d.empty? }.collect{|d| d.gsub(/^\x00|\xff$/, '') }
+ self.class.on_data_callbacks.each do |callback|
+ data.each do |message|
EM.next_tick { send(callback, message) }
end
-
- @buffer = []
- @buffering = false
- else
- @buffer.push(data) if @buffering
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.