This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Fork of libMiMic by Ryo Iizuka

Revision:
72:c118a7aa37a3
Child:
75:2a18df0ef111
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed/mod/ModJsonRpc.h	Fri Jun 13 11:06:33 2014 +0000
@@ -0,0 +1,60 @@
+#include "NyLPC_net.h"
+#include "ModBaseClass.h"
+#include "HttpdConnection.h"
+#include "Httpd.h"
+#include "Net.h"
+#include <vector>
+
+namespace MiMic
+{
+    class HttpdConnection;
+
+    /**
+     * This class is Websocket module.
+     * The class provides 3 services.
+     * <ul>
+     * <li>d.xml - a device description.</li>
+     * <li>control/xx - soap handler</li>
+     * <li>event/xx -event handler.</li>
+     * </ul>
+     */
+    class ModJsonRpc:ModBaseClass
+    {
+    private:
+    public:
+        const static int PARSE_ERROR=NyLPC_TJsonRpcErrorCode_PARSE_ERROR;
+        const static int INVALID_REQUEST=NyLPC_TJsonRpcErrorCode_INVALID_REQUEST;
+        const static int METHOD_NOT_FOUND=NyLPC_TJsonRpcErrorCode_METHOD_NOT_FOUND;
+        const static int INVALID_PARAMS=NyLPC_TJsonRpcErrorCode_INVALID_PARAMS;
+        const static int INTERNAL_ERROR=NyLPC_TJsonRpcErrorCode_INTERNAL_ERROR;
+        const static int SERVER_ERROR_BASE=NyLPC_TJsonRpcErrorCode_SERVER_ERROR_BASE;
+    private:
+        void** _objects;
+        const struct NyLPC_TJsonRpcClassDef** _rpc_table;
+    protected:
+        NyLPC_TcModJsonRpc_t* _mod;    
+    public:
+        ModJsonRpc();
+        /**
+         * @param i_rpc_table
+         * An address of Json RPC functions table.
+         */
+        ModJsonRpc(const char* i_path,const struct NyLPC_TJsonRpcClassDef** i_rpc_table);
+        virtual ~ModJsonRpc();
+        void setParam(const char* i_path,const struct NyLPC_TJsonRpcClassDef** i_rpc_table);        
+        /**
+         * This function prepares Json rpc loop with websocket negotiation.
+         * @return
+         * true if successful;otherwishe false.
+         */
+        bool execute(HttpdConnection& i_connection);
+        void dispatchRpcCall();
+        
+    public:
+        //for development
+        int addObject(void* i_object);
+        void* getObject(int i_oid);        
+        bool putResult(unsigned int i_id,const char* i_params_fmt,...);
+        bool putError(unsigned int i_id,int i_code);
+    };
+}
\ No newline at end of file