Class: Baleen::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/baleen/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(socket = nil) ⇒ Connection

Returns a new instance of Connection.



3
4
5
# File 'lib/baleen/connection.rb', line 3

def initialize(socket=nil)
  @socket = socket
end

Instance Method Details

#closeObject



23
24
25
# File 'lib/baleen/connection.rb', line 23

def close
  @socket.close
end

#notify_error(msg) ⇒ Object



15
16
17
# File 'lib/baleen/connection.rb', line 15

def notify_error(msg)
  notify_to_client(msg, "error")
end

#notify_exception(msg) ⇒ Object



27
28
29
30
# File 'lib/baleen/connection.rb', line 27

def notify_exception(msg)
  response = Baleen::Message::Exception.new({:message => msg})
  write(response.to_json)
end

#notify_info(msg) ⇒ Object



7
8
9
# File 'lib/baleen/connection.rb', line 7

def notify_info(msg)
  notify_to_client(msg, "info")
end

#notify_warn(msg) ⇒ Object



11
12
13
# File 'lib/baleen/connection.rb', line 11

def notify_warn(msg)
  notify_to_client(msg, "warn")
end

#respond(response) ⇒ Object



19
20
21
# File 'lib/baleen/connection.rb', line 19

def respond(response)
  write(response.to_json)
end