当前位置: 首页>>代码示例>>Python>>正文


Python Client.connect方法代码示例

本文整理汇总了Python中Client.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Client.connect方法的具体用法?Python Client.connect怎么用?Python Client.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Client的用法示例。


在下文中一共展示了Client.connect方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init

# 需要导入模块: import Client [as 别名]
# 或者: from Client import connect [as 别名]
def init(isclient, serverip, name, screen, clock):

    screen.fill((0, 0, 0))
    pygame.display.update()

    if isclient:
        try:
            host, port = serverip.split(":")
        except ValueError:
            host = serverip
            port = 12341
        Client.connect(host)
        Client.ready(name)

    else:
        try:
            host, port = serverip.split(":")
        except ValueError:
            host = ""
            port = 12341
        Server = server()

    while True:
        if not isclient:
            if Server.isdone():
                break
    for thing in Server.connected:
        print(thing.name)
开发者ID:Thenewprogramming,项目名称:paccatcher,代码行数:30,代码来源:Game.py

示例2: main

# 需要导入模块: import Client [as 别名]
# 或者: from Client import connect [as 别名]
def main():
  ADDR = getArg( "a", "127.0.0.1", "Address" )
  PORT = getArg( "p", 5005, "Port" )
  options = { 
    "name":getArg( "n", "User", "Name" ) 
  }

  # Create client
  CLIENT = Client( ADDR, PORT, options )

  # Connect to server
  #  This will enter the client main loop
  try:
    CLIENT.connect()
  except:
    pass

  CLIENT.close()
开发者ID:Alfwich,项目名称:school,代码行数:20,代码来源:ChatClient.py

示例3: connection

# 需要导入模块: import Client [as 别名]
# 或者: from Client import connect [as 别名]
def connection():
    Client.connect()
    identify=0
    essai=0
    while identify==0 and essai < 3:
        pseudo=raw_input("Entrer votre pseudonyme: ")
        password=getpass.getpass("Entrer le mot de passe: ")
        Client.sendMsg("L",pseudo+";,;"+password)
        rep=Client.receiveMsg()
        if(rep[1][9:]=="1"):
            identify=1
            break
        else:
            if(essai<2):
                print("Vous avez fais une erreur\nVeuillez recommencer")
            if(essai==2):
                print("Trop d'erreurs, au revoir")
                quit()
            essai=essai+1
    return identify
开发者ID:LorkScorguar,项目名称:Luchiana,代码行数:22,代码来源:LuchianaClient.py

示例4: Client

# 需要导入模块: import Client [as 别名]
# 或者: from Client import connect [as 别名]
max_throw_snowball_distance = 7


# Create our client
c = Client()

# Insert your key here
c.KEY = "g2lVRjJN96svcwTYPG8K0MmUfdQq6Xg1" 


# Tell the client to use this function to decide the next move.
# This function is defined above.
c.decide_move = dummy

# Connect to the game server
if c.connect():
	# If we successfully connected, start playing
	print 'Connected'

	# Tell the client to start listening for maps
	c.start()

	# Wait until the user presses a key
	raw_input('Press any key to quit...')

	# Tell the client to stop listening for maps
	c.stop()

	# Wait for the client to finish its last request
	c.join()
开发者ID:bobschriver,项目名称:UVB-Python-Bot,代码行数:32,代码来源:uvbbot-adv.py

示例5: Client

# 需要导入模块: import Client [as 别名]
# 或者: from Client import connect [as 别名]
    console.setLevel(log_level)

    # Set a format which is simpler for console use
    formatter = logging.Formatter('%(levelname)s: %(message)s')

    # Tell the handler to use this format
    console.setFormatter(formatter)

    if cfg.background is not 1:
        # Add the handler to the root logger
        logging.getLogger('').addHandler(console)

    # Start mldonkey Connection Phase without pool mode
    # Connect and start listener thread
    mldonkey = Client(cfg)
    mldonkey.connect()

    # Start listener thread to receive server msgs
    dbconnection = DBConnection.getInstance();
    dbconnection.setHost(cfg.dbhost)
    dbconnection.setDatabase(cfg.dbname) 
    dbconnection.setUser(cfg.dbuser) 
    dbconnection.setPassword(cfg.dbpass) 
    listener = Listener("Listener", mldonkey.connection, cfg)
    handler = MessageHandler(listener)
    #thread.start_new_thread(listener.start, ())
    thread.start_new_thread(handler.start, ())

    #while 1:time.sleep(0)
    while 1:pass
开发者ID:tassia,项目名称:DonkeySurvey,代码行数:32,代码来源:DonkeySurvey.py

示例6: MultiClientGame

# 需要导入模块: import Client [as 别名]
# 或者: from Client import connect [as 别名]
class MultiClientGame():
	pygame.mixer.pre_init(44100, -16, 2, 1024)
	pygame.mixer.init()

	def __init__(self, color):
		self.butterflies = []

		self.screen = pygame.display.get_surface()

		self.backgroundImage, self.backgroundRect = loadPNG("background.png")

		self.buttonSound = pygame.mixer.Sound("resources/sound/button.wav")
		self.buttonSound.set_volume(float(Resources.getOptionValue("sound"))/100)

		self.active = True

		self.level = Map(True)

		self.toolbar = GameToolbar()

		self.client = Client('localhost')
		self.client.connect()
		self.client.recieve()
		self.client.send(b"connexion avec serveur : OK")

		#MAP STRING RECIEVE
		mapStr = self.client.recieve(4096)
		mapStr = struct.unpack(str(len(mapStr)) + "s", mapStr)[0]

		#LOAD MAP FROM STRING
		self.level.saveFromStr("tempClient", mapStr)
		self.level.load("tempClient")

		#CREATE CLIENT RABBIT
		self.regis = Rabbit(1, "regis" , color, self.level.objectList, self.level.objectSpritesList)

		#SERVER RABBIT COLOR RECIEVE
		serverCol = self.client.recieve()
		serverCol = struct.unpack("iii", serverCol)

		#CLIENT RABBIT COLOR SEND
		self.client.send(struct.pack("iii", self.regis.color[0], self.regis.color[1], self.regis.color[2]))

		#CREATE SERVER RABBIT
	 	self.john = Rabbit(2, "john" , serverCol, self.level.objectList, self.level.objectSpritesList, True)

		self.regis.appendRabbit(self.john)
	 	self.john.appendRabbit(self.regis)

	 	self.pauseMenu = PauseGameMenu()

	# 	for l in range(0, 6):
	# 		while True:
	# 			randPos = random.randint(0, 16)
	# 			if not self.level.isInBlock(self.level.objectList[randPos].getX() + 10, self.level.objectList[randPos].getY() - 26):
	# 				break

	# 		butterfly = Butterfly(self.level.objectList[randPos].getX() + 10, self.level.objectList[randPos].getY() - 26, (255, 10, 100), self.level.objectList, self.level.objectSpritesList)
	# 		self.butterflies.append(butterfly)

	 	pygame.display.flip()

	def update(self):
	 	key = pygame.key.get_pressed()

	 	if self.active:
	 		pygame.mouse.set_visible(0)

	 		for event in pygame.event.get():
	 			if event.type == QUIT or (key[K_F4] and key[K_LALT]):
	 				return False, self

	 			elif event.type == KEYDOWN:
	 				if event.key == K_UP:
	 					self.regis.jump()
	 				if event.key == K_LEFT:
	 					self.regis.moveLeftStart()
	 				if event.key == K_RIGHT:
						self.regis.moveRightStart()
	 				if event.key == K_KP0:
	 					self.regis.throwCarrot()

	 			elif event.type == KEYUP:
					if event.key == K_LEFT:
						self.regis.moveLeftStop()
					if event.key == K_RIGHT:
						self.regis.moveRightStop()

	# 			#IF A RABBIT IS TOUCHED
	# 			elif event.type == USEREVENT + 1:
	# 				print "touche"
	# 				if self.john.isTouched():
	# 					self.john.moveLeftStop()
	# 					self.john.moveRightStop()

	# 				elif self.regis.isTouched():
	# 					self.regis.moveLeftStop()
	# 					self.regis.moveRightStop()

	# 			elif event.type == USEREVENT + 2:
#.........这里部分代码省略.........
开发者ID:Barbatos,项目名称:BumpNJump,代码行数:103,代码来源:MultiClientGame.py


注:本文中的Client.connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。