示例#1
0
 def usrLogin(self,request,context):
     if request.name=='__root__':
         self.loginDict[request.name]=1
         return DisStorage_pb2.loginInfo(
             loginFlag=1,
             IP=self.IP,
             accessNum = self.loginNum,
             mess = ''
         )
     if request.name in self.loginDict:
         return DisStorage_pb2.loginInfo(loginFlag=0,
                                         IP=self.IP,
                                         accessNum=self.loginNum,
                                         mess='You have logined')
     self.loginDict[request.name] = 1
     self.loginNum += 1
     return DisStorage_pb2.loginInfo(loginFlag = 1,
                                     IP = self.IP,
                                     accessNum=self.loginNum,
                                     mess = 'Login! you are the '+str(self.loginNum)+'th visitor\nServer time : '+time.strftime("%Y-%m-%d-%H:%M:%S",time.localtime(time.time()))+'\nIP : 127.0.0.1')
示例#2
0
 def usrLogin(self, request, context):
     for i in range(0, self.DisServerNum):
         if self.DisServerStress[i] < 5:
             res = self.stubs[i].usrLogin(request)
             if res.loginFlag == 1:
                 self.loginNum += 1
                 self.activeNum += 1
                 self.loginDict[request.name] = i
                 self.DisServerStress[i] += 1
             return res
     return DisStorage_pb2.loginInfo(loginFlag=0,
                                     IP='-1',
                                     accessNum=-1,
                                     mess='no free node')