Example #1
0
 def generate_reply(self, returned=None, optional=None):
   """This function is a bit crazy as it is entered from several points as both a callback or called directly :(
   returns either the successful msg, containing the symmertric key, balance, bank ip address, and login token
   OR
   the timeout until the client can log in again
   @param optional: text to return to the client with a code
   @type optional: [int, str]
   @return: None"""
   PROTOCOL = 1
   if self.successful:
     log_msg('Login was successful.', 3)
     EventLogging.save_event(BankLogin(username=self.username))
     #address of the bank server
     address = addressBook[0]
     curExp, nextExp = BankUtil.get_interval_time_deltas()
     format = '!BBIIII4sI'
     reply = struct.pack(format, PROTOCOL, 1, self.balance, Globals.CURRENT_ACOIN_INTERVAL[0], \
                                 curExp, nextExp, 
                                 inet_aton(address.host), address.port)
     reply += self.authBlob
   else:
     reply = struct.pack('!BBI', PROTOCOL, 0, self.timeout)
   #currently, 1 will replace the txt for a failure displayed client side, while 1 adds to it- thats all for now
   optional = [0, 'hello']
   if optional:
     code = struct.pack('!B', optional[0])
     reply += code + optional[1]
   #shove off the reply  
   self.reply(reply)
Example #2
0
 def reply(self, msg):
   balance = msg[0][0]
   curExp, nextExp = BankUtil.get_interval_time_deltas()
   reply = struct.pack('!IIII%ss'%(self.number), balance, Globals.CURRENT_ACOIN_INTERVAL[0],
                       curExp, nextExp,
                       self.returnSlip)
   self.encrypted_reply(reply)
   #log the event if anything was actually deposited:
   if self.amountEarned:
     eventLogger.aggregate_event("DEPOSITS", self.user, self.amountEarned)
Example #3
0
 def reply(self, msg):
     balance = msg[0][0]
     curExp, nextExp = BankUtil.get_interval_time_deltas()
     reply = struct.pack('!IIII%ss' % (self.number), balance,
                         Globals.CURRENT_ACOIN_INTERVAL[0], curExp, nextExp,
                         self.returnSlip)
     self.encrypted_reply(reply)
     #log the event if anything was actually deposited:
     if self.amountEarned:
         eventLogger.aggregate_event("DEPOSITS", self.user,
                                     self.amountEarned)