예제 #1
0
파일: spread.py 프로젝트: icej/py-spread
 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
예제 #2
0
파일: spread.py 프로젝트: icej/py-spread
 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)
예제 #3
0
파일: spread.py 프로젝트: jerluc/py-spread
 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
예제 #4
0
파일: spread.py 프로젝트: icej/py-spread
 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
예제 #5
0
파일: spread.py 프로젝트: jerluc/py-spread
 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',''))
예제 #6
0
파일: spread.py 프로젝트: icej/py-spread
 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', ''))
예제 #7
0
파일: spread.py 프로젝트: jerluc/py-spread
    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)
예제 #8
0
파일: spread.py 프로젝트: jerluc/py-spread
 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
예제 #9
0
파일: spread.py 프로젝트: icej/py-spread
    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)
예제 #10
0
파일: spread.py 프로젝트: icej/py-spread
 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
예제 #11
0
파일: spread.py 프로젝트: icej/py-spread
 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',''))
예제 #12
0
파일: spread.py 프로젝트: icej/py-spread
 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