Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free! Click here to download the new Pastebin App for iOS.
Guest

Untitled

By: a guest on Feb 22nd, 2012  |  syntax: Python  |  size: 1.28 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1.     def recieve(self, game, client):
  2.         # If we haven't received confirmation that we're connected yet, see if we should try again:
  3.         if not self.has_connected:
  4.             self.connection_timeout_timer -= 1
  5.  
  6.             if self.connection_timeout_timer <= 0 and self.retried_connection == False:
  7.                 self.connection_timeout_timer = constants.CLIENT_TIMEOUT
  8.                 # Send a reminder, in case the first packet was lost
  9.                 packet = networking.packet.Packet("client")
  10.                 packet.sequence = self.sequence
  11.                 packet.acksequence = self.client_acksequence
  12.  
  13.                 event = networking.event_serialize.Client_Event_Hello(client.player_name, client.server_password)
  14.                 packet.events.append((self.sequence, event))
  15.                 data = packet.pack()
  16.                 self.retried_connection=True
  17.                 print("retried_connection")
  18.                
  19.                 numbytes = self.socket.sendto(data, self.server_address)
  20.                 if len(data) != numbytes:
  21.                     # TODO sane error handling
  22.                     print("SERIOUS ERROR, NUMBER OF BYTES SENT != PACKET SIZE AT HELLO")
  23.             elif(self.retried_connection == True):
  24.                 raise Exception("No server found")