Permalink
Browse files

moving send_message to connection

  • Loading branch information...
1 parent d48a493 commit 6b76580a8ca19c0dec422a7146cb3bdb468e4452 @markburns committed Apr 18, 2012
Showing with 7 additions and 6 deletions.
  1. +6 −0 lib/slanger/connection.rb
  2. +1 −6 lib/slanger/subscription.rb
@@ -7,6 +7,12 @@ def initialize socket, socket_id=nil
end
def send *args
+ def send_message m
+ msg = JSON.parse(m)
+ s = msg.delete 'socket_id'
+ socket.send msg.to_json unless s == socket_id
+ end
+
socket.send format(*args)
end
@@ -4,6 +4,7 @@ class Subscription
def initialize socket, socket_id, msg
@payload = Payload.new socket, socket_id
+ delegate :send_message, to: :connection
@msg = msg
end
@@ -15,12 +16,6 @@ def handle
private
- def send_message m
- msg = JSON.parse(m)
- s = msg.delete 'socket_id'
- payload.socket.send msg.to_json unless s == payload.socket_id
- end
-
def channel
Channel.from channel_id
end

0 comments on commit 6b76580

Please sign in to comment.