Index: /PythonClient/.project
===================================================================
--- /PythonClient/.project	(revision 80)
+++ /PythonClient/.project	(revision 80)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>ObjectmqClient</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.python.pydev.PyDevBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.python.pydev.pythonNature</nature>
+	</natures>
+</projectDescription>
Index: /PythonClient/.pydevproject
===================================================================
--- /PythonClient/.pydevproject	(revision 80)
+++ /PythonClient/.pydevproject	(revision 80)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?eclipse-pydev version="1.0"?><pydev_project>
+<pydev_pathproperty name="org.python.pydev.PROJECT_SOURCE_PATH">
+<path>/ObjectmqClient/src</path>
+</pydev_pathproperty>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 2.7</pydev_property>
+<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Default</pydev_property>
+</pydev_project>
Index: /PythonClient/src/client/Client.py
===================================================================
--- /PythonClient/src/client/Client.py	(revision 80)
+++ /PythonClient/src/client/Client.py	(revision 80)
@@ -0,0 +1,101 @@
+'''
+Created on 03/07/2013
+
+@author: sergi
+'''
+import pika
+import uuid
+import json
+
+class Client(object):
+    '''
+    classdocs
+    '''
+    
+
+    def __init__(self, env):
+        '''
+        Constructor
+        '''
+        self.rpc_exchange = env.get('exchange', 'rpc_exchange')
+        self.reply_queue = env.get('reply_queue', 'reply_queue') 
+        
+        self.host = env.get('host', 'localhost')
+        self.port = env.get('port', 5672)   
+        self.ssl = env.get('ssl', False)
+        
+        self.credentials = pika.PlainCredentials(env.get('user', 'guest'), env.get('pass', 'guest'))
+        
+        self.connection = pika.BlockingConnection(pika.ConnectionParameters(host=self.host, port=self.port, credentials=self.credentials, ssl=self.ssl))
+         
+        self.channel = self.connection.channel()
+        
+        self.callback_queue = self.channel.queue_declare(queue=self.reply_queue)
+        
+        self.channel.basic_consume(self.on_response, no_ack=True, queue=self.reply_queue)
+        
+    def async_call(self, uid, method, params):
+        """ Async call this function will invoke the method 'method' with the params 'params' in the object binded with 'uid'"""
+        self.__async(uid, method, params, False)
+        
+    def multi_async_call(self, uid, method, params):
+        self.__async(uid, method, params, True)
+    
+    def __async(self, uid, method, params, multi):
+        if multi:
+            exch = "multi#" + uid
+        else:
+            exch = self.rpc_exchange
+        
+        corr_id = str(uuid.uuid4())
+        request = json.dumps({"method": method, "params": params, "id": corr_id, "async":"true"})
+        
+        props = pika.BasicProperties(app_id=uid, correlation_id=corr_id, reply_to="", type='gson')
+        
+        self.channel.basic_publish(exchange=exch, routing_key=uid, properties=props, body=request)
+        
+        print "UID: " + uid + ", exchange: " + exch + " ,corrId = " + corr_id + " , json: " + request
+            
+    def sync_call(self, uid, method, params):
+        self.response = None
+        self.corr_id = str(uuid.uuid4())
+        request = json.dumps({"method": method, "params": params, "id": self.corr_id, "async":"false"})
+        
+        props = pika.BasicProperties(app_id=uid, correlation_id=self.corr_id, reply_to="reply_queue", type='gson')
+        
+        self.channel.basic_publish(exchange=self.rpc_exchange, routing_key=uid, properties=props, body=request)
+        
+        print "UID: " + uid + ", exchange: " + self.rpc_exchange + " ,corrId = " + self.corr_id + " , json: " + request
+        
+        return self.__get_response()
+    
+    def multi_sync_call(self, uid, method, params, wait):
+        responses = []
+        self.response = None
+        self.corr_id = str(uuid.uuid4())
+        rpc_exchange = "multi#" + uid
+        request = json.dumps({"method": method, "params": params, "id": self.corr_id, "async":"false"})       
+        
+        props = pika.BasicProperties(app_id=uid, correlation_id=self.corr_id, reply_to="reply_queue", type='gson')
+        
+        self.channel.basic_publish(exchange=rpc_exchange, routing_key=uid, properties=props, body=request)
+        
+        print "UID: " + uid + ", exchange: " + rpc_exchange + " ,corrId = " + self.corr_id + " , json: " + request
+        i = 0
+        while i < wait:
+            responses.append(self.__get_response())
+            self.response = None
+            i = i + 1
+        return responses        
+    
+    def __get_response(self):
+        while  self.response is None:
+            self.connection.process_data_events()
+        return self.response
+    
+    def on_response(self, ch, method, props, body):
+        if self.corr_id == props.correlation_id:
+            result = json.loads(body)
+            self.response = result["result"]
+        
+        
Index: /PythonClient/src/client/ClientTest.py
===================================================================
--- /PythonClient/src/client/ClientTest.py	(revision 80)
+++ /PythonClient/src/client/ClientTest.py	(revision 80)
@@ -0,0 +1,61 @@
+'''
+Created on 04/07/2013
+
+@author: sergi
+'''
+import unittest
+from Client import Client
+import time
+
+class Test(unittest.TestCase):
+    env = {'user': 'guest', 'pass':'guest', 'host' : 'localhost', 'port': 5672, 'exchange': 'rpc_exchange'}
+    
+    client = Client(env)
+
+    def testAsync(self):
+        self.client.async_call("calculator", "fibonacci", [10])
+    
+    def testSyncAdd(self):
+        x = 10
+        y = 5
+        expected = x + y
+        actual = self.client.sync_call("calculator", "add", [x, y])
+        self.assertEqual(expected, actual)
+    
+    def testMultiSyncAdd(self):
+        x = 20
+        y = 10
+        expected = x + y
+        actual = self.client.multi_sync_call("calculator", "add", [x, y], 2)
+        self.assertEqual(expected, actual[0])
+        self.assertEqual(expected, actual[1])
+        
+    def testPi(self):
+        expected = 3.1415
+        actual = self.client.sync_call("calculator", "getPi", [])
+        self.assertEqual(expected, actual)
+    
+    def testContact(self):
+        address = {"street":"calle falsa", "number":2, "town":"Tgn"}
+        emails = ["asdf@gmail.com", "asdf@hotmail.com"]
+    
+        name1 = "Superman"
+        contact = {"name":name1, "surname":"T", "phone":"1234", "age":21, "address": address, "emails":emails}
+        self.client.async_call("list", "setContact", [contact])
+        time.sleep(1)
+    
+        name2 = "Batman"
+        contact = {"name":name2, "surname":"S", "phone":"1234", "age":22, "address": address, "emails":emails}
+        self.client.async_call("list", "setContact", [contact])
+        time.sleep(1)
+    
+        clist = self.client.sync_call("list", "getContacts", [])
+        c1 = clist[0]
+        c2 = clist[1]
+        
+        self.assertEqual(name1, c1['name'])
+        self.assertEqual(name2, c2['name'])
+    
+if __name__ == "__main__":
+    # import sys;sys.argv = ['', 'Test.testName']
+    unittest.main()
