Exemplo n.º 1
0
 def loginCheck(self, message): 
     '''登陆检查''' 
     result=parseCommMessage(message)
     protocolDebug(u"client_twisted.loginCheck result "+str(result))
     if result==True:
         #用户密码检测成功后,发送用户friendlist请求
         msg=friendListRequest(self.factory.user, self.factory.user)
         self.transport.write(msg)
         self.inused = 1
         protocolDebug(u"client_twisted.loginCheck 1 ok")
     if result==False:
         self.inused = 0
         protocolDebug(u"client_twisted.loginCheck 2 err")
Exemplo n.º 2
0
 def getFriends(self, message):
     '''获取friedns用户列表'''
     friendlist=parseCommMessage(message)
     try:
         protocolDebug(u"client_twisted.getFriends 3 user friends list " + repr(friendlist))
         protocolDebug(friendlist)
         self.factory.runControlFunction(self.factory.handleFriendlist,None,friendlist)
         #pylint: disable=W0702
     except:
         protocolDebug(u"client_twisted.getFriends 4 get user frends list err")    
     
     self.getFriendsFlag = 1       
     self.factory.runControlFunction(self.factory.handleSuccess,None,8002)
Exemplo n.º 3
0
def handleRefreshReceMessage(data, noUse):
    '''handleRefreshReceMessage'''
    noUse = noUse
    try:
        result = parseCommMessage(data[0])
        destinationAddress = result[1]
        sourceAddress = result[0]
        messageContents = result[2]
        showString = sourceAddress + " send to " + destinationAddress + ":" + '''"''' + messageContents + '''"'''
        frame.refreshReceMessage(showString)
        #pylint: disable=W0702
    except:
        pass    
Exemplo n.º 4
0
    def userCheck(self, usermessage):
        '''The first message form the client is user message ,it include user name and use password'''
        #检查用户登录请求信息 
        result = parseCommMessage(usermessage)
        self.connectuser = result[2]
        self.connectpassword = result[3]
        
        if self.factory.userflag == None:
            if self.factory.user.has_key(self.connectuser) == True:
                pass
            else:
                result = userLoginFailed(self.connectuser, self.connectuser, self.connectuser, self.connectpassword)
                protocolDebug("userCheck 1 user and password is wrong")
                self.transport.write(result)
                self.transport.loseConnection()
                return
            
            if self.factory.user[self.connectuser] == self.connectpassword:
                pass
            else:
                result = userLoginFailed(self.connectuser, self.connectuser, self.connectuser, self.connectpassword)
                protocolDebug("userCheck 2 user and password is wrong")
                self.transport.write(result)
                self.transport.loseConnection()
                return
        else:
            if self.factory.user.checkUser(self.connectuser, self.connectpassword) != userControlErrValue["OK"]:
                result = userLoginFailed(self.connectuser, self.connectuser, self.connectuser, self.connectpassword)
                protocolDebug("userCheck 3 user and password is wrong")
                self.transport.write(result)
                self.transport.loseConnection()
                return
                 
        if self.factory.userflag == None:                
            self.factory.clients.append(self) #在factory的连接队列中添加连接实例
            self.factory.clientConnect[self.connectuser] = self #保留用户和连接实例的字典
        else:
            if self.factory.user.getUserLogin(self.connectuser) != 1:
                self.factory.runControlFunction(self.factory.handleLoginUser, self, self.connectuser)
                self.factory.user.login(self.connectuser)
                self.factory.clients.append(self) #在factory的连接队列中添加连接实例
                self.factory.clientConnect[self.connectuser] = self #保留用户和连接实例的字典
            else:
                self.transport.loseConnection()
                return
                    
        self.inused = 1  #client已经登陆
        result = userLoginSucess(self.connectuser, self.connectuser, self.connectuser, self.connectpassword)
        self.transport.write(result)

        self.factory.runControlFunction(self.factory.handleSuccess, None, self.connectuser)
Exemplo n.º 5
0
 def messageCheck(self, message):
     '''消息检查,这里没有加密,使用明文传输'''
     result = parseCommMessage(message)
     self.destinationAddress = result[1] #目的连接地址
     self.sourceAddress = result[0]      #来源地址 
     self.messageContents = result[2]    #发送消息
     
     protocolDebug(u"server_twisted.xdServerProtocol.messageCheck 1 message: " + "src: " + self.destinationAddress + ", dst: " + self.sourceAddress)  
     protocolDebug(u"server_twisted.xdServerProtocol.messageCheck 1 message: " + "messageContents: " + self.messageContents )
     
     #察看消息发送的目的地址和来源地址是否有效
     if self.factory.userflag == None:
         if self.factory.user.has_key(self.sourceAddress) == True:
             if self.factory.user.has_key(self.destinationAddress) == True:
                 return 1 
         return 0    
     else:
         if self.factory.user.findUser(self.sourceAddress) == userControlErrValue["HaveUser"]:
             protocolDebug("HaveUser")
             if self.factory.user.findUserFriend(self.sourceAddress, self.destinationAddress) == userControlErrValue["OK"]:
                 protocolDebug("HaveFriend")
                 return 1
         return 0
Exemplo n.º 6
0
 def messageCheck(self, message):
     '''消息解析'''
     result=parseCommMessage(message)
     self.destinationAddress = result[1]
     self.sourceAddress = result[0]
     self.messageContents = result[2]