示例#1
0
    def __init__(self):
        self.ID = '/tmp/MDqueue'

        outQueueManager = QueueManager(address=('/tmp/SVSqueue'), \
            authkey='gnarf')
        outQueueManager.connect()

        inQueueManager = QueueManager(address=(self.ID), \
            authkey='gnarf')
        inQueueManager.connect()

        self.inQueue = inQueueManager.get_queue()
        self.outQueue = outQueueManager.get_queue()

        self.handleMsg = msgHandler()
        self.handleMsg.register('privateMsg', self.do_privateMsg)
        self.handleMsg.register('lobbyMsg', self.do_lobbyMsg)
        self.handleMsg.register('alert', self.do_alert)
        self.handleMsg.register('userJoined', self.do_userJoined)
        self.handleMsg.register('userLeft', self.do_userLeft)
        self.handleMsg.register('bye', self.do_bye)
        self.handleMsg.register('userList', self.do_userList)
        self.handleMsg.register('syslog', self.do_syslog)

        self.handleCmd = msgHandler(self.logfunc)
        self.handleCmd.register('userList', self.do_cmd_userList, 2)
        self.handleCmd.register('master', self.do_cmd_master, 3)
        self.handleCmd.register('shutdown', self.do_cmd_shutdown, 2)
        self.handleCmd.register('log', self.do_cmd_log, 2)

        self.userList = []
        self.masterList = []
        self.logList = []

        self.keep_alive = True
示例#2
0
    def __init__(self):
        inQueueManager = QueueManager(address=('/tmp/SVSqueue'), \
            authkey='gnarf')
        inQueueManager.connect()
        self.inQueue = inQueueManager.get_queue()

        self.handleMsg = msgHandler(self.logfunc)
        self.handleMsg.register('init', self.do_init)
        self.handleMsg.register('addClient', self.do_addClient)
        self.handleMsg.register('peerQuit', self.do_peerQuit)
        self.handleMsg.register('exit', self.do_exit)
        self.handleMsg.register('procDead', self.do_procDead)
        self.handleMsg.register('chatLobby', self.do_chatLobby)
        self.handleMsg.register('nameProposed', self.do_nameProposed)
        self.handleMsg.register('PINGsent', self.do_PINGsent)
        self.handleMsg.register('PINGreceived', self.do_PINGreceived)
        self.handleMsg.register('PONGreceived', self.do_PONGreceived)
        self.handleMsg.register('getUserList', self.do_getUserList)
        self.handleMsg.register('chatPrivate', self.do_chatPrivate, 3, False)
        self.handleMsg.register('shutdown', self.do_shutdown)
        self.handleMsg.register('syslog', self.do_syslog, 3, False)

        self.clients = {}
        self.lastClient = 0

        self.SVG = SVGhandler()

        self.init = False
        self.keep_alive = True
示例#3
0
 def __init__(self, port):
     self.ip = "10.148.0.5"  #socket.gethostbyname(socket.gethostname())
     self.port = port
     print(self.ip, self.port)
     self.userNum = 0
     self.Server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     try:
         self.Server.bind((self.ip, self.port))
     except socket.error as e:
         print("[EXCEPTION]", e)
     self._msghandler = msgHandler()
示例#4
0
    def __init__(self, queuepath, sock):
        self.ID = queuepath

        outQueueManager = QueueManager(address=('/tmp/SVSqueue'), \
            authkey='gnarf')
        outQueueManager.connect()

        inQueueManager = QueueManager(address=(queuepath), \
            authkey='gnarf')
        inQueueManager.connect()

        self.inQueue = inQueueManager.get_queue()
        self.outQueue = outQueueManager.get_queue()
        self.sock = sock

        self.inBuffer = ''

        self.handleMsg = msgHandler(self.logfunc)
        self.handleMsg.register('sock', self.do_sock)
        self.handleMsg.register('lobbyMsg', self.do_lobbyMsg)
        self.handleMsg.register('clientNameAccepted', \
            self.do_clientNameAccepted)
        self.handleMsg.register('clientNameDenied', \
            self.do_clientNameDenied)
        self.handleMsg.register('sendPONG', self.do_sendPONG)
        self.handleMsg.register('userList', self.do_userList)
        self.handleMsg.register('bye', self.do_bye)
        self.handleMsg.register('privateMsg', self.do_privateMsg, 3, False)
        self.handleMsg.register('userLeft', self.do_userLeft)
        self.handleMsg.register('userJoined', self.do_userJoined)

        self.handleProtIn = msgHandler()
        self.handleProtIn.register(210, self.do_210_in_proposeName, 2)
        self.handleProtIn.register(401, self.do_401_in_listRooms, 1)
        self.handleProtIn.register(406, self.do_406_in_newRoom, 1)
        self.handleProtIn.register(501, self.do_501_in_chatLobby)
        self.handleProtIn.register(502, self.do_502_in_chatPrivate)
        self.handleProtIn.register(505, self.do_505_in_getUserList, 1)
        self.handleProtIn.register(602, self.do_602_in_ackProt, 2)
        self.handleProtIn.register(603, self.do_603_in_PING, 1)
        self.handleProtIn.register(604, self.do_604_in_PONG, 1)
        self.handleProtIn.register(699, self.do_699_in_exit, 1)

        self.handleProtOut = msgHandler()
        self.handleProtOut.register(101, self.do_ProtOut_trivial)
        self.handleProtOut.register(302, self.do_ProtOut_trivial)
        self.handleProtOut.register(303, self.do_ProtOut_trivial)
        self.handleProtOut.register(305, self.do_ProtOut_trivial)
        self.handleProtOut.register(306, self.do_ProtOut_trivial)
        self.handleProtOut.register(503, self.do_503_out_chatLobby)
        self.handleProtOut.register(504, self.do_504_out_chatPrivate)
        self.handleProtOut.register(506, self.do_ProtOut_trivial)
        self.handleProtOut.register(507, self.do_507_out_userEntry)
        self.handleProtOut.register(508, self.do_ProtOut_trivial)
        self.handleProtOut.register(509, self.do_509_out_userJoined)
        self.handleProtOut.register(510, self.do_510_out_userLeft)
        self.handleProtOut.register(601, self.do_601_out_serverHello)
        self.handleProtOut.register(603, self.do_603_out_PING)
        self.handleProtOut.register(604, self.do_ProtOut_trivial)
        self.handleProtOut.register(697, self.do_ProtOut_trivial)

        self.FSMsymbols = {}
        self.FSM = StateMachine(self.FSMsymbols)
        self.FSM.add_state('init', self.st_init)
        self.FSM.set_state('init')
        self.FSM.add_state('prot_proposed', self.st_prot_proposed)
        self.FSM.add_state('prot_accepted', self.st_prot_accepted)
        self.FSM.add_state('name_asked', self.st_name_asked)
        self.FSM.add_state('online', self.st_online)

        self.userList = []

        self.firstCycle = True
        self.keep_alive = True