def disconnect(self): send_head = protocol_Create('KILL_MESS',self.private_name,[self.private_name]) self.socket_send(send_head) self.socket_send(struct.pack('!0s','')) self.sock = None self.private_name = None self.group = None
def multicast(self, groups, message): print groups, message data_len = len(message) send_head = protocol_Create('SEND_MESS',self.private_name,groups,data_len) self.socket_send(send_head) msg = struct.pack('!%ss'%data_len,message) self.socket_send(msg)
def disconnect(self): """ Disconnect from the spread daemon. The spread object should not be used after this call. >>> sp.disconnect() """ send_head = protocol_Create('KILL_MESS',self.private_name,[self.private_name]) self.socket_send(send_head) self.socket_send(struct.pack('!0s','')) self.sock = None self.private_name = None self.group = None
def disconnect(self): """ Disconnect from the spread daemon. The spread object should not be used after this call. >>> sp.disconnect() """ send_head = protocol_Create('KILL_MESS', self.private_name, [self.private_name]) self.socket_send(send_head) self.socket_send(struct.pack('!0s', '')) self.sock = None self.private_name = None self.group = None
def leave(self): """ leave the group with the given name. Return None. Upon failure, SpreadException is raised. >>> sp.leave() >>> try: >>> sp.leave() >>> except SpreadException spErr: >>> print spErr.err_msg """ send_head = protocol_Create('LEAVE_MESS',self.private_name,self.group) self.socket_send(send_head) self.socket_send(struct.pack('!0s',''))
def leave(self): """ leave the group with the given name. Return None. Upon failure, SpreadException is raised. >>> sp.leave() >>> try: >>> sp.leave() >>> except SpreadException spErr: >>> print spErr.err_msg """ send_head = protocol_Create('LEAVE_MESS', self.private_name, self.group) self.socket_send(send_head) self.socket_send(struct.pack('!0s', ''))
def multicast(self, groups, message): """ Send a message to all members of a group. Return the number of bytes sent @param groups: group list @param message: data >>> data = 'test spread multicast' >>> groups = ['group1'] >>> sp.multicast(groups, message) 21 """ data_len = len(message) send_head = protocol_Create('SEND_MESS',self.private_name,groups,data_len) self.socket_send(send_head) msg = struct.pack('!%ss'%data_len,message) return self.socket_send(msg)
def join(self, groups=[]): """ Join the group with the given name. Return None. Upon failure, SpreadException is raised. @param groups: group list >>> sp.join(['group1','group2']) >>> try: >>> sp.join(['group1','group2']) >>> except SpreadException spErr: >>> print spErr.err_msg """ val_g(groups) send_head = protocol_Create('JOIN_MESS',self.private_name,groups) self.socket_send(send_head) self.socket_send(struct.pack('!0s','')) self.group = groups
def multicast(self, groups, message): """ Send a message to all members of a group. Return the number of bytes sent @param groups: group list @param message: data >>> data = 'test spread multicast' >>> groups = ['group1'] >>> sp.multicast(groups, message) 21 """ data_len = len(message) send_head = protocol_Create('SEND_MESS', self.private_name, groups, data_len) self.socket_send(send_head) msg = struct.pack('!%ss' % data_len, message) return self.socket_send(msg)
def join(self, groups=[]): """ Join the group with the given name. Return None. Upon failure, SpreadException is raised. @param groups: group list >>> sp.join(['group1','group2']) >>> try: >>> sp.join(['group1','group2']) >>> except SpreadException spErr: >>> print spErr.err_msg """ val_g(groups) send_head = protocol_Create('JOIN_MESS', self.private_name, groups) self.socket_send(send_head) self.socket_send(struct.pack('!0s', '')) self.group = groups
def leave(self): send_head = protocol_Create('LEAVE_MESS',self.private_name,self.group) self.socket_send(send_head) self.socket_send(struct.pack('!0s',''))
def join(self, groups): send_head = protocol_Create('JOIN_MESS',self.private_name,groups) self.socket_send(send_head) self.socket_send(struct.pack('!0s','')) self.group = groups