Permalink
Browse files

Little bit of clean-up of WebSocket code.

  • Loading branch information...
1 parent 8ae33fe commit a729b37f3dd6c66ed66c3e9ae1a45746aa7f10ce @jcoglan jcoglan committed Aug 17, 2011
@@ -117,7 +117,6 @@ Faye.WebSocket.Protocol8Parser = Faye.Class({
frame[frame.length - 2] = Math.floor(error / 256);
frame[frame.length - 1] = error & 255;
}
- console.log([opcode, length, error, frame]);
socket.write(frame, 'binary');
socket.write(data, 'utf8');
@@ -77,8 +77,6 @@ def dispatch_event(event)
callback.call(event) if callback
end
- private
-
def encode(string, encoding = 'UTF-8')
return string unless string.respond_to?(:force_encoding)
string.force_encoding(encoding)
@@ -139,8 +139,9 @@ def frame(data, type = nil, error_type)
frame << 127.chr
frame << [length >> 32, length & 0xFFFFFFFF].pack('NN')
end
- frame << data
- frame
+
+ @socket.encode(frame, 'UTF-8') +
+ @socket.encode(data, 'UTF-8')
end
private

0 comments on commit a729b37

Please sign in to comment.