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)
def eject(self, clientChannel, reasonCode, reason): """ Kicks the client residing at the specified clientChannel, using the specifed reasoning. """ dg = PyDatagram() dg.addServerHeader(clientChannel, self.ourChannel, CLIENTAGENT_EJECT) dg.add_uint16(reasonCode) dg.addString(reason) self.send(dg)
def setClientState(self, clientChannel, state): """ Sets the state of the client on the CA. Useful for logging in and logging out, and for little else. """ dg = PyDatagram() dg.addServerHeader(clientChannel, self.ourChannel, CLIENTAGENT_SET_STATE) dg.add_uint16(state) 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)
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)
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 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)
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)