Created
August 12, 2009 00:06
Revisions
-
brianmario revised this gist
Nov 24, 2009 . 1 changed file with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,6 @@ def post_init @parser = Yajl::Parser.new @parser.on_parse_complete = method(:receive_object) @encoder = Yajl::Encoder.new end def receive_data(data) @@ -21,7 +20,9 @@ def receive_object(obj) def send_object(obj) # attempts to hand the caller 8kb chunks of the buffer as # it's being generated @encoder.encode(obj) do |chunk| send_data(chunk) end end end end -
brianmario revised this gist
Nov 24, 2009 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,7 @@ def post_init @parser = Yajl::Parser.new @parser.on_parse_complete = method(:receive_object) @encoder = Yajl::Encoder.new @encoder.on_progress = method(:send_data) end def receive_data(data) @@ -20,9 +21,7 @@ def receive_object(obj) def send_object(obj) # attempts to hand the caller 8kb chunks of the buffer as # it's being generated @encoder.encode(obj) end end end -
brianmario revised this gist
Aug 17, 2009 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,24 +4,24 @@ module JsonProtocol def post_init @parser = Yajl::Parser.new @parser.on_parse_complete = method(:receive_object) @encoder = Yajl::Encoder.new end def receive_data(data) @parser << data end # Invoked with ruby objects received over the network def receive_object(obj) # stub end # Sends a ruby object over the network def send_object(obj) # attempts to hand the caller 8kb chunks of the buffer as # it's being generated @encoder.encode(obj) do |chunk| send_data(chunk) end end end -
brianmario revised this gist
Aug 12, 2009 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,6 +18,8 @@ def receive_object obj # Sends a ruby object over the network def send_object obj # attempts to hand the caller 8kb chunks of the buffer as # it's being generated @encoder.encode(obj) do |chunk| send_data chunk end -
brianmario revised this gist
Aug 12, 2009 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ def post_init @encoder = Yajl::Encoder.new(:terminator => "\0") end def receive_data data @parser << data end -
brianmario created this gist
Aug 12, 2009 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ module EventMachine module Protocols module JsonProtocol def post_init @parser = Yajl::Parser.new @parser.on_parse_complete = method(:receive_object) @encoder = Yajl::Encoder.new(:terminator => "\0") end def receive_data data # :nodoc: @parser << data end # Invoked with ruby objects received over the network def receive_object obj # stub end # Sends a ruby object over the network def send_object obj @encoder.encode(obj) do |chunk| send_data chunk end end end end end