@@ -0,0 +1,2445 @@
+# -*- coding: utf8 -*-%0A%0A# Low-resource message queue framework%0A# Do RPC%0A# Copyright (c) 2016 Roman Kharin %3Cromiq.kh@gmail.com%3E%0A%0A# Permission is hereby granted, free of charge, to any person obtaining a copy%0A# of this software and associated documentation files (the %22Software%22), to deal%0A# in the Software without restriction, including without limitation the rights%0A# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell%0A# copies of the Software, and to permit persons to whom the Software is%0A# furnished to do so, subject to the following conditions:%0A%0A# The above copyright notice and this permission notice shall be included in%0A# all copies or substantial portions of the Software.%0A%0A# THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,%0A# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE%0A# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER%0A# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,%0A# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE%0A# SOFTWARE.%0A%0Aimport sys%0Aimport json%0A%0Afrom lrmq.client.sync import AgentIO%0A%0Aclass AgentIOCaller(AgentIO):%0A    %22Caller agent%22%0A    %0A    def init_loop(self):%0A        super().init_loop(True)%0A        print(%22CALLER%22, self.myid, file = sys.stderr)%0A        #self.reg_callback(self.myid, self.msg_self)%0A        self.subscribe_check(self.myid + %22/.*%22)%0A        print(%22CALL%22, %0A            self.call_aid, self.call_func, self.call_args, file = sys.stderr)%0A        ans = self.call(self.call_aid, self.call_func, self.call_args)%0A        print(%22RET%22, ans, file = sys.stderr)%0A        # leave hub%0A        self.exit_check()%0A        self.end_loop()%0A%0A    def start_loop(self, aid, func, args):%0A        self.call_aid = aid%0A        self.call_func = func%0A        self.call_args = args%0A        super().start_loop()%0A%0Adef main():%0A    if len(sys.argv) %3C 3:%0A        print()%0A        print(%22Usage:%22)%0A        print(%22%5Ctpython3 -m lrmq -a python test_rpc.py %3Caid%3E %3Cfunc%3E %3Cargs%3E%22)%0A        print(%22Where:%22)%0A        print(%22%5Ctaid - agent id%22)%0A        print(%22%5Ctfunc - function name%22)%0A        print(%22%5Ctargs - json formatted aguments ('%5B1, 2, 3%5D')%22)%0A    else:%0A        a = AgentIOCaller()%0A        args = json.loads(sys.argv%5B3%5D)%0A        a.start_loop(sys.argv%5B1%5D, sys.argv%5B2%5D, args)%0A%0Aif __name__ == %22__main__%22:%0A    main()%0A

Add test for calling rpc from command line