Created
July 31, 2009 05:51
-
-
Save eklitzke/159104 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def make_hdr(self, replyto=None, srcnode=None): | |
hdr = rucksack.interface.MsgHdr() | |
hdr.msgid = str(rucksack.util.rand64()) | |
if replyto is not None: | |
hdr.replyto = replyto | |
if srcnode is not None: | |
hdr.srcnode = self.node | |
return hdr | |
def notify_membership(self, fd, events, ev): | |
"""Callback to send a membership notification. | |
This callback is scheduled as a persistent callback that creates a | |
transient callback to send an announce message when the socket is | |
writeable. | |
""" | |
def send_notification(fd, events, ev): | |
msg = rucksack.interface.JoinMsg() | |
msg.hdr.CopyFrom(self.make_hdr()) | |
#msg.nodes = [] | |
print 'sent!' | |
self.sock.sendall(msg.SerializeToString()) | |
notify_timer = libevent.create_timer(self.notify_membership) | |
notify_timer.add_to_loop(self.JOIN_FREQ) | |
self.add_event(libevent.EV_WRITE, send_notification) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment