lib/msgr/client.rb in msgr-0.11.0 vs lib/msgr/client.rb in msgr-0.11.1

- old
+ new

@@ -72,11 +72,11 @@ end def publish(payload, opts = {}) mutex.synchronize do check_process! - connection.publish payload, opts + sync_publish payload, opts end end def routes mutex.synchronize do @@ -92,9 +92,25 @@ connection.release end end private + + def sync_publish(payload, opts) + begin + payload = MultiJson.dump(payload) + opts[:content_type] ||= 'application/json' + rescue + opts[:content_type] ||= 'application/text' + end + + sync_publish_message payload.to_s, opts + end + + def sync_publish_message(message, opts) + connection.publish message, opts + end + def mutex @mutex end def check_process!