예제 #1
0
파일: xipmsg.py 프로젝트: ZhuZhengyi/xipmsg
    def run(self):
        while True:
            try:
                msg = raw_input() #get user input
                msgsquence = msg.strip().split(':') #strip the input and explode the string by ":"
                #print msgsquence
                msgsquence2 = msgsquence[0].strip().split('/');
                host = string.join(msgsquence2[1], '')
                msg = msgsquence[1:]
                msg = string.join(msg, ':')
                
                protocol.sendmsg(self.client_socket, host, msg)
                protocol.printhost()
                print ">"

            except EOFError:
                protocol.logout()
                print "byte byte"
                os.abort()
        s.close()
예제 #2
0
파일: xipmsg.py 프로젝트: nranjan54/xipmsg
    def run(self):
        while True:
            try:
                msg = raw_input()  #get user input
                msgsquence = msg.strip().split(
                    ':')  #strip the input and explode the string by ":"
                #print msgsquence
                msgsquence2 = msgsquence[0].strip().split('/')
                host = string.join(msgsquence2[1], '')
                msg = msgsquence[1:]
                msg = string.join(msg, ':')

                protocol.sendmsg(self.client_socket, host, msg)
                protocol.printhost()
                print ">"

            except EOFError:
                protocol.logout()
                print "byte byte"
                os.abort()
        s.close()
예제 #3
0
파일: xipmsg.py 프로젝트: nranjan54/xipmsg
    def run(self):
        while True:
            try:
                data, (addr, port) = self.server_socket.recvfrom(1024)
                strlist = data.split(':')
                commandword = strlist[4]
                #print repr(strlist)
                if commandword == protocol.commandword['IPMSG_SENDMSG']:
                    remotehost = addr
                    msg = strlist[5]
                    protocol.optresp(commandword, remotehost)
                    protocol.printhost()
                    #print '#ipmsg_sendmsg>'
                    print strlist[2], "@", remotehost, ">",
                    print msg
                    print ">"
                    #sys.stdout.write(">")
                elif commandword == protocol.commandword[
                        'IPMSG_SENDMSG_WITHCHECK']:
                    msgnum = strlist[1]
                    remotehost = addr
                    protocol.sendrecvmsg(client_socket, remotehost,
                                         msgnum)  #send msg check

                    msg = strlist[5]
                    protocol.optresp(commandword, remotehost)
                    protocol.printhost()
                    print strlist[2], "@", remotehost, ">",
                    print msg
                    print ">"
                elif commandword == protocol.commandword['IPMSG_ANSENTRY']:
                    remotehost = addr
                    protocol.optresp(protocol.commandword['IPMSG_ANSENTRY'],
                                     remotehost)
                elif commandword == protocol.commandword['IPMSG_BR_EXIT']:
                    remotehost = addr
                    protocol.optresp(protocol.commandword['IPMSG_BR_EXIT'],
                                     remotehost)
                elif commandword == protocol.commandword['IPMSG_NOOPERATION']:
                    #no operation
                    pass
                elif commandword == protocol.commandword['IPMSG_BR_ENTRY']:
                    remotehost = addr
                    protocol.optresp(protocol.commandword['IPMSG_BR_ENTRY'],
                                     remotehost)
                    protocol.sendansentry(client_socket, remotehost)
                elif commandword == protocol.commandword['IPMSG_ANSENTRY']:
                    remotehost = addr
                    protocol.optresp(protocol.commandword['IPMSG_ANSENTRY'],
                                     remotehost)
                else:
                    print "Notice > Uncatched message :", strlist, ":", commandword
                    print ">"

                protocol.printhost()

            except socket.timeout:
                pass

        s.close()
예제 #4
0
파일: xipmsg.py 프로젝트: ZhuZhengyi/xipmsg
    def run(self):
        while True:
            try:
                data, (addr, port) = self.server_socket.recvfrom(1024)
                strlist = data.split(':')
                commandword = strlist[4]
                #print repr(strlist)
                if commandword == protocol.commandword['IPMSG_SENDMSG'] :
                    remotehost = addr
                    msg = strlist[5]
                    protocol.optresp(commandword, remotehost)
                    protocol.printhost()
                    #print '#ipmsg_sendmsg>'
                    print strlist[2],"@",remotehost,">",
                    print msg
                    print ">"
                    #sys.stdout.write(">")
                elif commandword == protocol.commandword['IPMSG_SENDMSG_WITHCHECK'] :
                    msgnum = strlist[1]
                    remotehost = addr
                    protocol.sendrecvmsg(client_socket, remotehost, msgnum) #send msg check

                    msg = strlist[5]
                    protocol.optresp(commandword, remotehost)
                    protocol.printhost()
                    print strlist[2],"@",remotehost,">",
                    print msg
                    print ">"
                elif commandword == protocol.commandword['IPMSG_ANSENTRY'] :
                    remotehost = addr
                    protocol.optresp(protocol.commandword['IPMSG_ANSENTRY'], remotehost)
                elif commandword == protocol.commandword['IPMSG_BR_EXIT'] :
                    remotehost = addr
                    protocol.optresp(protocol.commandword['IPMSG_BR_EXIT'], remotehost)
                elif commandword == protocol.commandword['IPMSG_NOOPERATION'] :
                    #no operation
                    pass
                elif commandword == protocol.commandword['IPMSG_BR_ENTRY'] :
                    remotehost = addr
                    protocol.optresp(protocol.commandword['IPMSG_BR_ENTRY'], remotehost)
                    protocol.sendansentry(client_socket, remotehost)
                elif commandword == protocol.commandword['IPMSG_ANSENTRY'] :
                    remotehost = addr
                    protocol.optresp(protocol.commandword['IPMSG_ANSENTRY'], remotehost)
                else :
                    print "Notice > Uncatched message :",strlist, ":" , commandword
                    print ">"


                protocol.printhost()

            except socket.timeout:
                pass

        s.close()