All pastes #596102 Raw Edit

Mine

public text v1 · immutable
#596102 ·published 2007-06-29 20:07 UTC
rendered paste body
import socket # Modulo para comunicacion en red
import pickle # Modulo empacador
import GameLogic as G # El modulo mas sexi

C = G.getCurrentController()
O = C.getOwner()

# Check if server is already conected (see script ServidorCon)
if O.Conectado == 1: # This is a property in the object Main
  # Flag for recieved data
  rec = 1

  # Recieve data from client
  try:
    recData = G.conn.recvfrom(1024)
    data = recData[0]
  except:
    rec = 0

  # If data is recieved
  if rec == 1:
    if data:
      # Unpack Client Data
      G.DatosCliente = pickle.loads(data)
      # Send data to client, this global list is filled
	  # from various other scripts to be sent in a single package
	  # to the cient
      data = pickle.dumps(G.DatosServidor)
      G.conn.sendto(data, recData[1])

    else:
      # Close conection
      G.conn.close()
      # Disconected
      O.Conectado = "FALSE"