Ejemplo n.º 1
0
 def sendHello(self):
     dg = PyDatagram()
     dg.add_uint16(CLIENT_HELLO)
     dg.add_uint32(self.get_dc_file().get_hash())
     dg.add_string(base.config.GetString('server-version',
                                         'no-version-set'))
     self.send(dg)
Ejemplo n.º 2
0
    def clientAddSessionObject(self, clientChannel, doId):
        """
        Declares the specified DistributedObject to be a "session object",
        meaning that it is destroyed when the client disconnects.
        Generally used for avatars owned by the client.
        """

        dg = PyDatagram()
        dg.addServerHeader(clientChannel, self.ourChannel,
                           CLIENTAGENT_ADD_SESSION_OBJECT)
        dg.add_uint32(doId)
        self.send(dg)
    def sendHello(self, version_string = None):
        # If the string is passed as an argument, use that.
        if version_string == None:
            # Or, get the string from the loaded prc files.
            version_string = base.config.GetString('server-version', '')
            if version_string == '':
                self.notify.error('server-version is missing in your configuration files.  It is needed in order to send \'CLIENT_HELLO\' to the server.')

        dg = PyDatagram()
        dg.add_uint16(CLIENT_HELLO)
        dg.add_uint32(self.get_dc_file().get_hash())
        dg.add_string(version_string)
        self.send(dg)
Ejemplo n.º 4
0
    def clientAddInterest(self, clientChannel, interestId, parentId, zoneId):
        """
        Opens an interest on the behalf of the client. This, used in conjunction
        with add_interest: visible (or preferably, disabled altogether), will mitigate
        possible security risks.
        """

        dg = PyDatagram()
        dg.addServerHeader(clientChannel, self.ourChannel,
                           CLIENTAGENT_ADD_INTEREST)
        dg.add_uint16(interestId)
        dg.add_uint32(parentId)
        dg.add_uint32(zoneId)
        self.send(dg)
Ejemplo n.º 5
0
 def sendAddInterest(self, context, interest_id, parent_id, zone_id):
     dg = PyDatagram()
     dg.add_uint16(CLIENT_ADD_INTEREST)
     dg.add_uint32(context)
     dg.add_uint16(interest_id)
     dg.add_uint32(parent_id)
     dg.add_uint32(zone_id)
     self.send(dg)
Ejemplo n.º 6
0
 def sendAddInterest(self, context, interest_id, parent_id, zone_id):
     dg = PyDatagram()
     dg.add_uint16(CLIENT_ADD_INTEREST)
     dg.add_uint32(context)
     dg.add_uint16(interest_id)
     dg.add_uint32(parent_id)
     dg.add_uint32(zone_id)
     self.send(dg)
Ejemplo n.º 7
0
 def sendAddInterestMultiple(self, context, interest_id, parent_id, zone_ids):
     dg = PyDatagram()
     dg.add_uint16(CLIENT_ADD_INTEREST_MULTIPLE)
     dg.add_uint32(context)
     dg.add_uint16(interest_id)
     dg.add_uint32(parent_id)
     dg.add_uint16(len(zone_ids))
     for zone_id in zone_ids:
         dg.add_uint32(zone_id)
     self.send(dg)
 def sendAddInterestMultiple(self, context, interest_id, parent_id, zone_ids):
     dg = PyDatagram()
     dg.add_uint16(CLIENT_ADD_INTEREST_MULTIPLE)
     dg.add_uint32(context)
     dg.add_uint16(interest_id)
     dg.add_uint32(parent_id)
     dg.add_uint16(len(zone_ids))
     for zone_id in zone_ids:
         dg.add_uint32(zone_id)
     self.send(dg)
Ejemplo n.º 9
0
    def _parse_msg_hton(self, msgid, data):
        msg = PyDatagram()
        msg.add_uint8(msgid)

        if msgid == MessageTypes.update_entity:
            msg.add_uint32(data['netid'])
            msg.add_string(data['data'])
        elif msgid == MessageTypes.remove_entity:
            msg.add_uint32(data['netid'])
        elif msgid == MessageTypes.register_player:
            pass
        elif msgid == MessageTypes.player_id:
            msg.add_uint32(data['netid'])
        elif msgid == MessageTypes.player_input:
            msg.add_uint32(data['netid'])
            msg.add_int8(data['movement_x'])
            msg.add_string(data['action_set'])
        else:
            raise RuntimeError("Unknown msgid:", msgid)

        return msg
Ejemplo n.º 10
0
    def _parse_msg_hton(self, msgid, data):
        msg = PyDatagram()
        msg.add_uint8(msgid)

        if msgid == MessageTypes.update_entity:
            msg.add_uint32(data['netid'])
            msg.add_string(data['data'])
        elif msgid == MessageTypes.remove_entity:
            msg.add_uint32(data['netid'])
        elif msgid == MessageTypes.register_player:
            pass
        elif msgid == MessageTypes.player_id:
            msg.add_uint32(data['netid'])
        elif msgid == MessageTypes.player_input:
            msg.add_uint32(data['netid'])
            msg.add_int8(data['movement_x'])
            msg.add_string(data['action_set'])
        else:
            raise RuntimeError("Unknown msgid:", msgid)

        return msg
Ejemplo n.º 11
0
 def sendRemoveInterest(self, context, interest_id):
     dg = PyDatagram()
     dg.add_uint16(CLIENT_REMOVE_INTEREST)
     dg.add_uint32(context)
     dg.add_uint16(interest_id)
     self.send(dg)
Ejemplo n.º 12
0
 def sendHello(self, version_string):
     dg = PyDatagram()
     dg.add_uint16(CLIENT_HELLO)
     dg.add_uint32(self.get_dc_file().get_hash())
     dg.add_string(version_string)
     self.send(dg)
 def clientRemoveSessionObject(self, clientChannel, doId):
     dg = PyDatagram()
     dg.addServerHeader(clientChannel, self.ourChannel,
                        CLIENTAGENT_REMOVE_SESSION_OBJECT)
     dg.add_uint32(doId)
     self.send(dg)
Ejemplo n.º 14
0
 def sendRemoveInterest(self, context, interest_id):
     dg = PyDatagram()
     dg.add_uint16(CLIENT_REMOVE_INTEREST)
     dg.add_uint32(context)
     dg.add_uint16(interest_id)
     self.send(dg)
Ejemplo n.º 15
0
 def sendHello(self, version_string):
     dg = PyDatagram()
     dg.add_uint16(CLIENT_HELLO)
     dg.add_uint32(self.get_dc_file().get_hash())
     dg.add_string(version_string)
     self.send(dg)