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


Python Client.close方法代码示例

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


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

示例1: main

# 需要导入模块: import Client [as 别名]
# 或者: from Client import close [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

示例2: __init__

# 需要导入模块: import Client [as 别名]
# 或者: from Client import close [as 别名]

#.........这里部分代码省略.........
    ##            tablePlayerText = self.font.render("johnnash", True, (0,0,0))
    ##            tablePlayerNumCards = self.font.render("-Cards: 00", True, (0,0,0))
    ##            tablePlayerStrikes = self.font.render("-Strikes: 0", True, (0,0,0))
    ##            tablePlayerStatus = self.font.render("-Status: a", True, (0,0,0))
    ##            self.screen.blit(tablePlayerText, pos)
    ##            self.screen.blit(tablePlayerNumCards, (pos[0]+15, pos[1] + 45))
    ##            self.screen.blit(tablePlayerStrikes, (pos[0]+15, pos[1] + 30))
    ##            self.screen.blit(tablePlayerStatus, (pos[0]+15, pos[1]+15))
    ##
    ##            #if player.status == "a":
    ##            self.screen.blit(tableActiveMarker, (pos[0]-10, pos[1]))
    ##            #if player is self.client.player:
    ##            tableYouMarker = self.font.render("<- You!", True, (255,0,0))
    ##            self.screen.blit(tableYouMarker, (pos[0]+55, pos[1]))
    ##            #posCnt += 1
    ##
    ##
    ##        cardDrawPositions = [(225,275), (275, 275),(325, 275), (375,275)]
    ##        #if self.client.lastPlay:
    ##            #posCnt = 0
    ##        lastPlayText = self.font3.render("Last Play:", True, (0,0,0))
    ##        self.screen.blit(lastPlayText, (100, 275))
    ##        for pos in cardDrawPositions:
    ##            tableCardText = self.font3.render("52", True, (0,0,0))
    ##            self.screen.blit(tableCardText, pos)
    ##            posCnt += 1
    ##
    ##        #draw hand
    ##        yourHandText = self.font.render("Your Hand:", True, (0,0,0))
    ##        self.screen.blit(yourHandText, (210, 325))
    ##        #if self.client.hand:
    ##        posCnt = 0
    ##        for i in range(17):
    ##            handCardText = self.font.render("22", True, (0,0,0))
    ##            if posCnt < 8:
    ##                self.screen.blit(handCardText, (275 + posCnt * 25, 325))
    ##            elif posCnt < 16:
    ##                self.screen.blit(handCardText, (275 + (posCnt-8) * 25, 345))
    ##            else:
    ##                self.screen.blit(handCardText, (275 + (posCnt-16)*25, 365))
    ##            posCnt += 1
    ##
    ##        #draw text boxes
    ##        self.playTextBox.draw(self.screen)
    ##        self.swapTextBox.draw(self.screen)
    ##        self.chatTextBox.draw(self.screen)
    ##
    ##
    ##
    ##        pygame.display.update()

    def run(self):
        self.running = 1
        self.clientThread = threading.Thread(target=self.client.run)
        self.clientThread.start()

        while self.running:
            keystate = pygame.key.get_pressed()
            events = pygame.event.get()
            for event in events:
                if event.type == QUIT or keystate[K_ESCAPE]:
                    self.client.close()
                    self.running = 0
            self.draw()
            self.clock.tick(100)
            text = None
            if self.client.manual:
                # get text input
                if self.client.active:
                    text = self.playTextBox.update(events)
                    if text:
                        if text == "pass":
                            cplay = "[cplay|52,52,52,52]"
                        else:
                            cards = text.split()
                            ##                            for card in cards:
                            ##                                if card in self.client.hand:
                            ##                                    self.client.hand.remove(card)
                            while len(cards) < 4:
                                cards.append("52")
                            cplay = "[cplay|{0},{1},{2},{3}]".format(cards[0], cards[1], cards[2], cards[3])
                        self.client.sock.send(cplay)
                        self.client.active = False
                        self.client.sock.send("[chand]")
                elif self.client.swapping:
                    text = self.swapTextBox.update(events)
                    if text:
                        cswap = "[cswap|" + text + "]"
                        self.client.sock.send(cswap)
                        self.client.swapping = False
                else:
                    text = self.chatTextBox.update(events)
                    # if text is input
                    if text:
                        if self.client.isConnected:
                            cchat = self.client.makeCchat(text)
                            self.client.sock.send(cchat)

        pygame.quit()
        self.clientThread.join()
开发者ID:jhm520,项目名称:367Project,代码行数:104,代码来源:guiClient.py


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