def send2market(command, data, doAck=False, PacketID=None): """ Same - send a packet to Market server. """ MyID = misc.getLocalID() RemoteID = settings.MarketServerID() if PacketID is None: PacketID = packetid.UniqueID() packet = dhnpacket.dhnpacket( command, MyID, MyID, PacketID, data, RemoteID,) transport_control.outbox(packet, doAck) return PacketID
def send2central(command, data, doAck=False, PacketID=None): """ A method to prepare a packet for Central server and send it to the transport gate. """ MyID = misc.getLocalID() RemoteID = settings.CentralID() if PacketID is None: PacketID = packetid.UniqueID() packet = dhnpacket.dhnpacket( command, MyID, MyID, PacketID, data, RemoteID,) transport_control.outbox(packet, doAck) #del packet return PacketID
def SendToID(idurl, AckHandler=None, Payload=None, NeedAck=False, wide=False): dhnio.Dprint(8, "identitypropagate.SendToID [%s] NeedAck=%s" % (nameurl.GetName(idurl), str(NeedAck))) thePayload = Payload if thePayload is None: thePayload = misc.getLocalIdentity().serialize() packet = dhnpacket.dhnpacket( commands.Identity(), misc.getLocalID(), #MyID, misc.getLocalID(), #MyID, misc.getLocalID(), #PacketID, thePayload, idurl) if AckHandler is not None: transport_control.RegisterInterest(AckHandler, packet.RemoteID, packet.PacketID) transport_control.outbox(packet, NeedAck, wide) if wide: # this is a ping packet - need to clear old info transport_control.ErasePeerProtosStates(idurl) transport_control.EraseMyProtosStates(idurl)