lib/angelo/base.rb in angelo-0.1.4 vs lib/angelo/base.rb in angelo-0.1.5
- old
+ new
@@ -3,11 +3,11 @@
class Base
include ParamsParser
include Celluloid::Logger
extend Forwardable
- def_delegators :@responder, :content_type, :headers, :request
+ def_delegators :@responder, :content_type, :headers, :redirect, :request
@@addr = DEFAULT_ADDR
@@port = DEFAULT_PORT
@@ping_time = DEFAULT_PING_TIME
@@ -132,21 +132,22 @@
end
end
async :ping_websockets do
every(@@ping_time) do
- websockets.each do |ws|
+ websockets.all.each do |ws|
ws.socket << ::WebSocket::Message.ping.to_data
end
end
end
class WebsocketsArray < Array
include Celluloid::Logger
@@peeraddrs = {}
@@socket_context = {}
+ @@websockets = {}
def initialize server, context = nil
@context, @server = context, server
super()
end
@@ -179,11 +180,14 @@
@@peeraddrs.delete ws
end
def [] context
raise ArgumentError.new "symbol required" unless Symbol === context
- @@websockets ||= {}
@@websockets[context] ||= self.class.new @server, context
+ end
+
+ def all
+ a = self + @@websockets.values.flatten
end
end
end