From 7ef2b0415ee3d4d3c3d69f47ba9476c139a9cd26 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 2 Mar 2018 14:15:27 +0200 Subject: [PATCH] Events mode --- iguana/exchanges/LP_commands.c | 5 ++++- iguana/exchanges/mm.c | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 22248209d..5e15a0cc5 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -233,7 +233,7 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ } else if ( strcmp(method,"getendpoint") == 0 ) { - int32_t err; + int32_t err,mode; retjson = cJSON_CreateObject(); if ( IPC_ENDPOINT >= 0 ) { @@ -250,6 +250,9 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ jaddstr(retjson,"result","success"); jaddstr(retjson,"endpoint","ws://127.0.0.1:5555"); jaddnum(retjson,"socket",IPC_ENDPOINT); + mode = NN_WS_MSG_TYPE_TEXT; + err = nn_setsockopt(IPC_ENDPOINT,NN_SOL_SOCKET,NN_WS_MSG_TYPE,&mode,sizeof(mode)); + jaddnum(retjson,"sockopt",err); } else { diff --git a/iguana/exchanges/mm.c b/iguana/exchanges/mm.c index d29ea015d..68227c110 100644 --- a/iguana/exchanges/mm.c +++ b/iguana/exchanges/mm.c @@ -180,6 +180,24 @@ int main(int argc, const char * argv[]) } exit(0); } + else if ( argv[1] != 0 && strcmp(argv[1],"events") == 0 ) + { + int32_t len; void *ptr; + if ( (IPC_ENDPOINT= nn_socket(AF_SP,NN_PAIR)) >= 0 ) + { + if ( nn_connect(IPC_ENDPOINT,"ws://127.0.0.1:5555") >= 0 ) + { + while ( 1 ) + { + if ( (len= nn_recv(IPC_ENDPOINT,&ptr,NN_MSG,0)) > 0 ) + { + printf("nn_recv[%d] (%s)\n",len,(char *)ptr); + nn_freemsg(ptr); + } + } + } + } + } else if ( argv[1] != 0 && strcmp(argv[1],"hush") == 0 ) { uint32_t timestamp; char str[65],wifstr[128]; bits256 privkey; int32_t i;