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


Python ConnectionManager.ConnectionManager类代码示例

本文整理汇总了Python中net.ConnectionManager.ConnectionManager的典型用法代码示例。如果您正苦于以下问题:Python ConnectionManager类的具体用法?Python ConnectionManager怎么用?Python ConnectionManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Main

class Main(DirectObject):

    def __init__(self):
        
        # Network Setup
        self.cManager = ConnectionManager()
        self.startConnection()
        
        #taskMgr.add(self.menu, "Menu")
        base.win.setClearColor(Vec4(0,0,0,1))
        self.imageObject = OnscreenImage(parent = render2d, image = 'images/mainPage.png', pos = (0,0,0), scale = (1.444, 1, 1.444))
        self.imageObject.setTransparency(TransparencyAttrib.MAlpha)
        
        self.button = DirectButton(image ='images/button.png',pos = (-.1,0,-.25), relief = None, scale = .40,
                                    command = self.startWorld)
        self.button.setTransparency(TransparencyAttrib.MAlpha)

        #self.cAudio = 
        

    def startConnection(self):
        """Create a connection to the remote host.
        If a connection cannot be created, it will ask the user to perform
        additional retries.
        """
        if self.cManager.connection == None:
            if not self.cManager.startConnection():
                return False

        return True
    
    def menu(self, task):
        # Accept raw_input choice
        choice = input("1 - Rand int\n2 - Rand string\n3 - Rand short\n4 - Rand float\n6 - Exit\n")
        
        msg = 0
        
        if choice is 1: msg = random.randint(-(2**16), 2**16 - 1)
        elif choice is 2: msg = ''.join(random.choice('abcdefghijklmnopqrstuvwxyz') for x in range(7))
        elif choice is 3: msg = random.randint(0, 2**16 - 1)
        elif choice is 4: msg = 100 * random.random()
        elif choice is 6: sys.exit()
        else: print "Invalid input"
        
        
        self.cManager.sendRequest(choice, msg);
        

    def startWorld(self):
        #send login request
        
        print "elll"
开发者ID:jaimodha,项目名称:MMOG,代码行数:52,代码来源:Main.py

示例2: Main

class Main(DirectObject):

    def __init__(self):
        
	    # Network Setup
        self.cManager = ConnectionManager()
        self.startConnection()
        print "Ran Main"
        #taskMgr.add(self.menu, "Menu")
        self.login = login()
        print "Finished"
    def startConnection(self):
        """Create a connection to the remote host.

        If a connection cannot be created, it will ask the user to perform
        additional retries.

        """
        if self.cManager.connection == None:
            if not self.cManager.startConnection():
                return False

        return True
    
    def menu(self, task):
        # Accept raw_input choice
        self.login = login()
        if self.login.getStatus() == "Authorized":
            print "going to character Select Menu"
            return task.done
        
        return task.again
开发者ID:jaimodha,项目名称:MMOG,代码行数:32,代码来源:Main.py

示例3: __init__

 def __init__(self, lobby):
     self.playerList = {}
     self.userList = []
     self.otherPlayersDataAvailable = False
     self.lobby = lobby
     self.gameWorld = World(self)
     self.loadinScreen = LoadingScreen(self.gameWorld)
     self.lobby.World.ServerConnection.activeStatus = False
     self.cManager = ConnectionManager(self, self.lobby.World.ServerConnection)
     self.cManager.startConnection()
     self.gameWorld.cManager = self.cManager
     self.cManager.sendRequest(Constants.CMSG_REQ_TEST)
     self.addVehicleProps(self.lobby.World.username, 0, 0, 0, 0, 0, 0, 0, 0, 0)
     # self.cManager.sendRequest(Constants.CMSG_SET_POSITION)
     # while not self.otherPlayersDataAvailable:
     # print "Wait for respponse"
     # sleep(1)
     # Fake player creation for the time being
     # x = 10
     # y = 10
     # z = 0
     # print "LOBBY LIST: ", self.lobby.playerList
     # if len(self.lobby.playerList) > 0:
     #     for idx, player in enumerate(self.lobby.playerList):
     #         if player != None:
     #             print "Creating -", player
     #             self.addPlayer(player, 1, 0, 0, x, y, z, 0, 0, 0)
     #             x += 10
     #             y += 10
     taskMgr.add(self.startGameTask, "startGameTask")
开发者ID:genusgant,项目名称:CS594-ThrottleThunder-GameClient,代码行数:30,代码来源:RRMain.py

示例4: __init__

    def __init__(self):
        __builtin__.main = self
        self.taskMgr = taskMgr
        self.base = base
        
        # Connect to the server
        self.cManager = ConnectionManager()
        self.startConnection()
    
        self.characters = dict()
        self.cpList = dict()
        
        # Login as 'CPHandler'
        # Temporary workaround, can add a seperate request/response for client/NPC client logins later
        self.username = "CPHandler"
        type = 0
        factionId = 0
        self.cManager.sendRequest(Constants.CMSG_AUTH, [self.username, type, factionId])

        # Create control points
        self.cpList[1] = BasicControlPoint(1, 210.984, 115.005, 0, 10, RED)
        self.cpList[2] = BasicControlPoint(2, 141.016, 0.440607, 0, 10, RED)
        self.cpList[3] = BasicControlPoint(3, -0.766843, 9.40588, 0, 10, RED)
        self.cpList[4] = BasicControlPoint(4, -210.771, 113.753, 0, 10, BLUE)
        self.cpList[5] = BasicControlPoint(5, -149.953, 0.674369, 0, 10, BLUE)

        taskMgr.doMethodLater(0.1, self.refresh, "heartbeat")
        taskMgr.doMethodLater(1, self.CPHandler, 'CPHandler')
开发者ID:jaimodha,项目名称:MMOG,代码行数:28,代码来源:ControlPointClient.py

示例5: __init__

    def __init__(self):
        self.frame = None
        self.buttonFrame = None
        self.dl = None
        self.dl2 = None
        self.dl3 = None
        self.regSel = None
        self.loginSel = None
        self.uid = None
        self.pwd = None
        self.reg = None
        self.submit = None
        self.lbl = None
        self.errorLbl = None

        self.directRadioButtonHandler = None

        print "UserGUIHandler Init"
        self.playerId = ""
        self.loginState = -1
        self.registerState = -1
        self.worldManager = finalhw1.WorldManager()
        self.world = self.worldManager.w
        self.connectionManager = ConnectionManager(self)
        self.world.setConnectionManager(self.connectionManager)
        self.connectionManager.startConnection()
开发者ID:debasishgt,项目名称:dd-team,代码行数:26,代码来源:uid-pwd.py

示例6: submitRRegister

 def submitRRegister(self):
     print "username: "+self.usernameEntry.get()
     print "password: "+self.passwordEntry.get()
     print "re-password: "+self.rePasswordEntry.get()
     self.registerUsername = self.usernameEntry.get().strip()
     self.registerPassword = self.passwordEntry.get().strip()
     self.registerCPassword = self.rePasswordEntry.get().strip()
     self.passwordEntry.enterText("")
     self.rePasswordEntry.enterText("")
     try:
         self.cManager = ConnectionManager()
         self.startConnection()
         print ""
     except Exception:
         self.error = True
     
     if self.error is False:
         if self.registerPassword == self.registerCPassword and self.registerPassword.strip() != "" and self.registerUsername.strip() != "":
             print "Success (",self.registerUsername, ", ",self.registerPassword,", ",self.registerCPassword,")"
             self.cManager.sendRequest(Constants.CMSG_REGISTER, (self.registerUsername, self.registerPassword))
             self.cancel()
         else:
             taskMgr.add(self.errorMessage, "destroyIncorrectUsername")
             self.message()
             print "Failed (",self.registerUsername, ", ",self.registerPassword,", ",self.registerCPassword,")"
     else:
         print "Cannot Connect to the Server"
开发者ID:jaimodha,项目名称:MMOG,代码行数:27,代码来源:login.py

示例7: __init__

    def __init__(self):
        
	    # Network Setup
        self.cManager = ConnectionManager(self)
        self.cManager.startConnection()
        
        taskMgr.add(self.menu, "Menu")
开发者ID:genusgant,项目名称:CS594-GameDevelopment-Protocols,代码行数:7,代码来源:Main.py

示例8: __init__

    def __init__(self):
	    # Network Setup
        self.cManager = ConnectionManager(self)
        self.startConnection()
        self.login = login(self)
        self.name = ""
        self.w = None
开发者ID:bpascard,项目名称:CS454HW2,代码行数:7,代码来源:Main.py

示例9: __init__

 def __init__(self):
     print 'Loading Login...'
     self.cManager = ConnectionManager()
     self.startConnection()
     frame = DirectFrame(frameColor=(0, 0, 0, 1), #(R,G,B,A)
                         frameSize=(-1, 1, -1, 1),#(Left,Right,Bottom,Top)
                         pos=(-0.5, 0, 0.5))
     self.createLoginWindow()
开发者ID:genusgant,项目名称:CS594-GameDevelopment-Protocols,代码行数:8,代码来源:login.py

示例10: __init__

 def __init__(self):
     print 'Loading character selection...'
     self.cManager = ConnectionManager()
     self.startConnection()
     frame = DirectFrame(frameColor=(0, 0, 0, 1), #(R,G,B,A)
                         frameSize=(-3, 3, -3, 3),#(Left,Right,Bottom,Top)
                         pos=(-0.5, 0, 0.5))
     self.createCreateCharWindow()
开发者ID:jaimodha,项目名称:MMOG,代码行数:8,代码来源:selectcharandteamtype.py

示例11: __init__

 def __init__(self, usernameInput):
     self.currentUser = usernameInput
     print 'Loading character selection...'
     self.cManager = ConnectionManager(self)
     self.startConnection()
     frame = DirectFrame(frameColor=(0, 0, 0, 1), #(R,G,B,A)
                         frameSize=(-3, 3, -3, 3),#(Left,Right,Bottom,Top)
                         pos=(-0.5, 0, 0.5))
     self.createSelectionWindow()
开发者ID:bpascard,项目名称:CS454HW2,代码行数:9,代码来源:characterSelection.py

示例12: __init__

    def __init__(self):
        
	    # Network Setup
        self.cManager = ConnectionManager()
        self.startConnection()
        print "Ran Main"
        #taskMgr.add(self.menu, "Menu")
        self.login = login()
        print "Finished"
开发者ID:jaimodha,项目名称:MMOG,代码行数:9,代码来源:Main.py

示例13: __init__

    def __init__(self):
        __builtin__.main = self
        self.taskMgr = taskMgr
        self.base = base
        
        # Connect to the server
        self.cManager = ConnectionManager()
        self.startConnection()
    
        self.characters = dict()
        self.cpList = dict()

        base.win.setClearColor(Vec4(0,0,0,1))


        self.environ = loader.loadModel("models/world")
        self.environ.reparentTo(render)
        self.environ.setPos(0,0,0)
        self.ralphStartPos = self.environ.find("**/start_point").getPos()

        # Create a floater object.  We use the "floater" as a temporary
        # variable in a variety of calculations.

        self.floater = NodePath(PandaNode("floater"))
        self.floater.reparentTo(render)

        self.accept("escape", sys.exit)
        
        # Login as 'CPHandler'
        # Temporary workaround, can add a seperate request/response for client/NPC client logins later
        self.name = "CPHandler"
        factionId = 0
        self.cManager.sendRequest(Constants.CMSG_AUTH, [self.name, factionId])

        # Create two control points
        cp1 = ControlPoint(1, -107.575, 0.6066, 0.490075, 10, RED)
        cp2 = ControlPoint(2, -100.575, -35.6066, 0.090075, 10, BLUE)

        self.cpList[1] = cp1
        self.cpList[2] = cp2

        taskMgr.doMethodLater(0.1, self.refresh, "heartbeat")
        taskMgr.doMethodLater(1, self.CPHandler, 'CPHandler')

        # Set up the camera
        base.disableMouse()
        #base.camera.setPos(self.character.actor.getX(),self.character.actor.getY()+10,2)

        # Create some lighting
        ambientLight = AmbientLight("ambientLight")
        ambientLight.setColor(Vec4(.3, .3, .3, 1))
        directionalLight = DirectionalLight("directionalLight")
        directionalLight.setDirection(Vec3(-5, -5, -5))
        directionalLight.setColor(Vec4(1, 1, 1, 1))
        directionalLight.setSpecularColor(Vec4(1, 1, 1, 1))
        render.setLight(render.attachNewNode(ambientLight))
        render.setLight(render.attachNewNode(directionalLight))
开发者ID:jaimodha,项目名称:MMOG,代码行数:57,代码来源:ControlPointClient.py

示例14: __init__

 def __init__(self):
     __builtin__.main=self
     #self.loginEntry = []
     self.createLogin();
     self.dict = {} 
     try:
         self.cManager = ConnectionManager()
         self.startConnection()
     except Exception:
         self.error = True
开发者ID:jaimodha,项目名称:MMOG,代码行数:10,代码来源:login.py

示例15: __init__

    def __init__(self):
        self.emitter = EventEmitter()
        self.cManager = ConnectionManager(self)

        self.tester = Tester(self)

        if self.startConnection():
            loadPrcFileData("", "window-type none") # disable graphics
            loadPrcFileData("", "audio-library-name null") # disable audio
            ShowBase.__init__(self)
            self.cManager.initTasks()
            self.emitter.emit('connection')
            self.run()
开发者ID:isitso,项目名称:cs454-game-dd-test-client,代码行数:13,代码来源:nettest.py


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