Class: SPSMessenger

Inherits:
SPSSub
  • Object
show all
Defined in:
lib/sps_messenger.rb

Instance Method Summary collapse

Instance Method Details

#start(watchx: false, pub_host: 'sps', pub_port: '59000', client_id: Socket.gethostname) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/sps_messenger.rb', line 28

def start(watchx: false, pub_host: 'sps', pub_port: '59000', 
          client_id: Socket.gethostname)
  
  Curses.init_screen
  #x = Curses.cols / 2  # We will center our text
  x = 0
  y = Curses.lines / 2
  Curses.setpos(y, x)  # Move the cursor to the center of the screen
  curs_set(0) # invisible cursor
  start_color
  init_pair(COLOR_GREEN, COLOR_GREEN,COLOR_BLACK) 
  init_pair(COLOR_YELLOW,COLOR_YELLOW,COLOR_BLACK)
  attron(color_pair(COLOR_GREEN)|A_NORMAL){ addstr('ready ') }
  refresh()
  
  Thread.new { watch_xset(pub_host, pub_port, client_id) } if watchx

  subscribe(topic: 'messenger | ' + client_id + '/messenger')
  
end