Skip to content

Commit

Permalink
README, client fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
winton committed Jan 16, 2011
1 parent 49e4318 commit 3f78afc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Original file line Diff line number Diff line change
@@ -1,8 +1,10 @@
Puggernaut Puggernaut
=========== ==========


Simple server push implementation using eventmachine and long polling. Simple server push implementation using eventmachine and long polling.


![Puggernaut](http://cloud.github.com/downloads/winton/puggernaut/puggernaut.png)

Requirements Requirements
------------ ------------


Expand Down
23 changes: 5 additions & 18 deletions lib/puggernaut/client.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,26 +1,13 @@
module Puggernaut module Puggernaut
class Client class Client


def initialize(env, servers) def initialize(env='development', servers={})
Puggernaut.env = env Puggernaut.env = env


loop do EM.epoll if EM.epoll?
begin @connections = servers.inject([]) do |array, (host, port)|
GC.start logger.info "#{Time.now} Starting TCP client for #{host}:#{port}"
EM.epoll if EM.epoll? array << EM.connect(host, port, Tcp)
EM.run do
@connections = servers.inject([]) do |array, (host, port)|
logger.info "#{Time.now} Starting TCP client for #{host}:#{port}"
array << EM.connect(host, port, Tcp)
end
end
rescue Interrupt
logger.info "#{Time.now} Shuting down client..."
exit
rescue
logger.error "#{Time.now} Error: " + $!.message
logger.error "\t" + $!.backtrace.join("\n\t")
end
end end
end end


Expand Down
2 changes: 1 addition & 1 deletion lib/puggernaut/client/tcp.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def say(messages)
end end


def send_data(data) def send_data(data)
callback{ super(data) } callback { super(data) }
end end


def unbind def unbind
Expand Down

0 comments on commit 3f78afc

Please sign in to comment.