Skip to content
Browse files

rename output_hash to cached_json_hash

  • Loading branch information...
1 parent e2d2fd6 commit 1f71ec0fab0b0772f42b0fc9d0501db8736b5646 @piotrmarat committed
Showing with 25 additions and 11 deletions.
  1. +11 −10 lib/socky/server.rb
  2. +13 −0 lib/socky/server/cached_json_hash.rb
  3. +1 −1 lib/socky/server/channel/base.rb
View
21 lib/socky/server.rb
@@ -10,14 +10,15 @@ module Socky
module Server
ROOT = File.expand_path(File.dirname(__FILE__))
- autoload :Application, "#{ROOT}/server/application"
- autoload :Channel, "#{ROOT}/server/channel"
- autoload :Config, "#{ROOT}/server/config"
- autoload :Connection, "#{ROOT}/server/connection"
- autoload :HTTP, "#{ROOT}/server/http"
- autoload :Logger, "#{ROOT}/server/logger"
- autoload :Message, "#{ROOT}/server/message"
- autoload :Misc, "#{ROOT}/server/misc"
- autoload :WebSocket, "#{ROOT}/server/websocket"
+ autoload :Application, "#{ROOT}/server/application"
+ autoload :Channel, "#{ROOT}/server/channel"
+ autoload :Config, "#{ROOT}/server/config"
+ autoload :Connection, "#{ROOT}/server/connection"
+ autoload :HTTP, "#{ROOT}/server/http"
+ autoload :Logger, "#{ROOT}/server/logger"
+ autoload :Message, "#{ROOT}/server/message"
+ autoload :Misc, "#{ROOT}/server/misc"
+ autoload :WebSocket, "#{ROOT}/server/websocket"
+ autoload :CachedJsonHash, "#{ROOT}/server/cached_json_hash"
end
-end
+end
View
13 lib/socky/server/cached_json_hash.rb
@@ -0,0 +1,13 @@
+module Socky
+ module Server
+ class CachedJsonHash < Hash
+ include Misc
+
+ def to_json
+ @json ||= super
+ end
+
+ end
+ end
+end
+
View
2 lib/socky/server/channel/base.rb
@@ -51,7 +51,7 @@ def remove_subscriber(connection)
def deliver(connection, message)
return unless connection.nil? || (subscribers[connection.id] && subscribers[connection.id]['write'])
- send_data({ 'event' => message.event, 'channel' => self.name, 'data' => message.user_data })
+ send_data(CachedJsonHash['event' => message.event, 'channel' => self.name, 'data' => message.user_data ])
end
protected

1 comment on commit 1f71ec0

@piotrmarat
Owner

Wrong message for commit. Next commit has a proper message

Please sign in to comment.
Something went wrong with that request. Please try again.