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

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers NyLPC_cModJsonRpc.h Source File

NyLPC_cModJsonRpc.h

00001 /*********************************************************************************
00002  * PROJECT: MiMic
00003  * --------------------------------------------------------------------------------
00004  *
00005  * This file is part of MiMic
00006  * Copyright (C)2011 Ryo Iizuka
00007  *
00008  * MiMic is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU Lesser General Public License as published
00010  * by the Free Software Foundation, either version 3 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  *
00021  * For further information please contact.
00022  *  http://nyatla.jp/
00023  *  <airmail(at)ebony.plala.or.jp> or <nyatla(at)nyatla.jp>
00024  *
00025  *********************************************************************************/
00026 #ifndef NYLPC_CMODJSONRPC_H_
00027 #define NYLPC_CMODJSONRPC_H_
00028 #include "NyLPC_http.h"
00029 #include "../NyLPC_cHttpdConnection.h"
00030 #include "NyLPC_cModWebSocket.h"
00031 #ifdef __cplusplus
00032 extern "C" {
00033 #endif /* __cplusplus */
00034 
00035 /**
00036  * WebSocketストリームからJSONRPC電文を取り込むモジュールです。
00037  */
00038 typedef struct NyLPC_TcModJsonRpc NyLPC_TcModJsonRpc_t;
00039 
00040 
00041 /**
00042  * クラス構造体
00043  */
00044 struct NyLPC_TcModJsonRpc
00045 {
00046     NyLPC_TcModWebSocket_t super;
00047     NyLPC_TcJsonRpcParser_t _rpc_parser;
00048     union NyLPC_TJsonRpcParserResult _result;
00049 };
00050 
00051 
00052 void NyLPC_cModJsonRpc_initialize(NyLPC_TcModJsonRpc_t* i_inst,const NyLPC_TChar* i_ref_root_path,const struct NyLPC_TJsonRpcClassDef** i_class_tbl);
00053 void NyLPC_cModJsonRpc_finalize(NyLPC_TcModJsonRpc_t* i_inst);
00054 #define NyLPC_cModJsonRpc_canHandle(i,c) NyLPC_cModWebSocket_canHandle(&((i)->super),(c))
00055 #define NyLPC_cModJsonRpc_close(i,t) NyLPC_cModWebSocket_close(&((i)->super),(t))
00056 
00057 
00058 NyLPC_TBool NyLPC_cModJsonRpc_execute(NyLPC_TcModJsonRpc_t* i_inst,NyLPC_TcHttpdConnection_t* i_connection);
00059 
00060 /**
00061  * Execute実行後に繰り返し実行できます。
00062  * trueを返却した場合は、NyLPC_cModJsonRpc_getRpcCall関数で結果を取得できるか調べてください。
00063  * @return
00064  * JSONRPCの処理を継続して行えるかを返します。
00065  * falseの場合、JSONRPCの構文解析は失敗し、Websocketは閉じられます。Websocketの受信ループを終了してください。
00066  */
00067 NyLPC_TBool NyLPC_cModJsonRpc_processRpcMessage(NyLPC_TcModJsonRpc_t* i_inst);
00068 
00069 /**
00070  * JSONRPCの構文解析結果を返します。
00071  * @return
00072  * JSONRPC電文が確定した場合、結果を格納した構造体を返します。構造体の有効期限は、次回にNyLPC_cModJsonRpc_processRpcMessageを実行するまでです。
00073  * NULLを返した場合は、引き続きNyLPC_cModJsonRpc_processRpcMessageを実行する必要があります。
00074  */
00075 const union NyLPC_TJsonRpcParserResult* NyLPC_cModJsonRpc_getMessage(NyLPC_TcModJsonRpc_t* i_inst);
00076 
00077 NyLPC_TBool NyLPC_cModJsonRpc_putResult(NyLPC_TcModJsonRpc_t* i_inst,NyLPC_TUInt32 i_id,const NyLPC_TChar* i_params_fmt,...);
00078 NyLPC_TBool NyLPC_cModJsonRpc_putResultV(NyLPC_TcModJsonRpc_t* i_inst,NyLPC_TUInt32 i_id,const NyLPC_TChar* i_params_fmt,va_list i_a);
00079 NyLPC_TBool NyLPC_cModJsonRpc_putError(NyLPC_TcModJsonRpc_t* i_inst,NyLPC_TUInt32 i_id,NyLPC_TInt32 i_code);
00080 
00081 #ifdef __cplusplus
00082 }
00083 #endif /* __cplusplus */
00084 
00085 #endif /* NYLPC_CMODJSONRPC_H_ */