def read_message(self):
        """ read a complete message from the device """

        data = ""
        while len(data) < 4:
            data += self.sock.recv(4)
        
        msg_length, data = cc_message.extract_length_header(data) 
        while len(data) < msg_length:
            data += self.sock.recv(2048)
            
       
        message_dict = cc_message.extract_message(data)
        
        message = {}
        
        try:
            message = json.loads(message_dict['data'])
        except:
            pass
        
        #print message_dict['namespace']
        #print json.dumps(message, indent=4, separators=(',', ': '))
        
        return message   
    def read_message(self):
        """ read a complete message from the device """

        data = None
        while data == None:
            data = self.sock.recv(4)
        
        msg_length, data = cc_message.extract_length_header(data) 
        while len(data) < msg_length:
            data += self.sock.recv(2048)
            
       
        message_dict = cc_message.extract_message(data)
        
        message = {}
        
        try:
            message = json.loads(message_dict['data'])
        except:
            pass
        
        #print message_dict['namespace']
        #print json.dumps(message, indent=4, separators=(',', ': '))
        
        return message