Sha256: f688f090927f2c17fb2347138a73b4fa112fe66dc67a771bb917896488b21e19
Contents?: true
Size: 709 Bytes
Versions: 19
Compression:
Stored size: 709 Bytes
Contents
## # This class provides methods for EventSource connection instance. # @attr [EM::Connection] connection the connection instance of EventMachine class Midori::EventSource attr_accessor :connection # Init a EventSource instance with a connection # @param [EM::Connection] connection the connection instance of EventMachine def initialize(connection) @connection = connection end # Send data and close the connection # @param [String] data data to be sent def send(data) raise Midori::Exception::EventSourceTypeError unless data.is_a? String @connection.send_data(data.split("\n").map {|str| "data: #{str}\n"}.join + "\n") @connection.close_connection_after_writing end end
Version data entries
19 entries across 19 versions & 1 rubygems