diff options
Diffstat (limited to 'cholerab/cholerab-live/cholerab.py')
-rwxr-xr-x | cholerab/cholerab-live/cholerab.py | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/cholerab/cholerab-live/cholerab.py b/cholerab/cholerab-live/cholerab.py index 0ac44e09..b6b3f84f 100755 --- a/cholerab/cholerab-live/cholerab.py +++ b/cholerab/cholerab-live/cholerab.py @@ -2,22 +2,35 @@ # -*- coding: utf-8 -*- import curses,time from view import CursesView +from chol_net import CholerabMulicastNet import logging logging.basicConfig(filename='here.log',level=logging.DEBUG) log = logging.getLogger('main') -def main(scr): +class Cholerab: + def __init__(self): + self.view = CursesView(cholerab=self) + self.transport = CholerabMulicastNet(cholerab=self) + def send_char(self,x,y,char): + log.info("Sending %s at (%d,%d) to connected peers" %(char,x,y)) + self.transport.send_char(x,y,char) + + def write_char(self,x,y,char,user): + log.info("Writing %s at (%d,%d) from %d to view" %(char,x,y,user)) + self.view.write_char(x,y,char,user) + def stop(self): + self.view.stop() + self.transport.stop() + def main(self): + self.view.start() + self.transport.start() + self.view.join() + #after view dies, kill the transport as well + self.transport.stop() + self.transport.join() +def main(): log.debug('started main') - a = CursesView(scr=scr) - a.start() - log.debug - a.write_char(5,5,'p') - a.write_char(6,5,'e') - a.write_char(7,5,'n') - a.write_char(8,5,'i') - a.write_char(9,5,'s') - a.write_str(5,6,'¯\(°_o)/¯',user=2) - for i in range(7,11): - time.sleep(2) - a.write_str(5,i,'¯\(°_o)/¯',user=3) - a.join() -curses.wrapper(main) + chol = Cholerab() + chol.main() + +if __name__ == "__main__": + main() |