|
@@ -96,8 +96,8 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
char *substr = NULL;
|
|
|
int count = 0;
|
|
|
int i = 0;
|
|
|
- int c = 0;
|
|
|
- int templen = 0;
|
|
|
+
|
|
|
+
|
|
|
char key_value[VALUE_MAX_LENGTH];
|
|
|
|
|
|
|
|
@@ -112,6 +112,10 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
strcpy(tempin, (const char *)in);
|
|
|
memset( (void *)in, 0, sizeof(char)*len );
|
|
|
|
|
|
+
|
|
|
+ MsgType = json_object_get_int(json_object_array_get_idx(json_tokener_parse(tempin), 0));
|
|
|
+ sprintf(UniqueId, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 1)));
|
|
|
+
|
|
|
|
|
|
if(strcmp((const char *)tempin,"[ ]") == 0)
|
|
|
{
|
|
@@ -121,22 +125,23 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
|
|
|
if(tempin[0] != '\0')
|
|
|
{
|
|
|
- MsgType = tempin[1] - '0';
|
|
|
+
|
|
|
|
|
|
- c = 0;
|
|
|
+
|
|
|
|
|
|
if((MsgType != 2) && (MsgType != 3) && (MsgType != 4) )
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
while ((tempin[4+c] != '\"') && (tempin[4+c] != '\0'))
|
|
|
{
|
|
|
UniqueId[c] = tempin[4+c];
|
|
|
|
|
|
c++;
|
|
|
}
|
|
|
- UniqueId[c] = '\0';
|
|
|
+ UniqueId[c] = '\0';*/
|
|
|
|
|
|
|
|
|
if(UniqueId[0] == '\0')
|
|
@@ -150,7 +155,7 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
{
|
|
|
case MESSAGE_TYPE_CALL:
|
|
|
|
|
|
-
|
|
|
+
|
|
|
c = 0;
|
|
|
while (tempin[4+4+strlen(UniqueId)-1+c] != '\"')
|
|
|
{
|
|
@@ -158,10 +163,10 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
|
|
|
c++;
|
|
|
}
|
|
|
- Action[c] = '\0';
|
|
|
-
|
|
|
+ Action[c] = '\0';*/
|
|
|
+ sprintf(Action, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 2)));
|
|
|
|
|
|
-
|
|
|
+
|
|
|
c = 0;
|
|
|
templen= 4+4+3+strlen(UniqueId)-1+strlen(Action)-1;
|
|
|
while ((c+ templen) < (strlen(tempin)-1))
|
|
@@ -170,14 +175,15 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
|
|
|
c++;
|
|
|
}
|
|
|
- Payload[c] = '\0';
|
|
|
-
|
|
|
+ Payload[c] = '\0';*/
|
|
|
|
|
|
+
|
|
|
+ sprintf(Payload, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 3)));
|
|
|
CallHandler(UniqueId,Action,Payload);
|
|
|
break;
|
|
|
|
|
|
case MESSAGE_TYPE_CALLRESULT:
|
|
|
-
|
|
|
+
|
|
|
c = 0;
|
|
|
templen= 4+3+strlen(UniqueId)-1;
|
|
|
while ((c+ templen) < (strlen(tempin)-1))
|
|
@@ -186,13 +192,13 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
|
|
|
c++;
|
|
|
}
|
|
|
- Payload[c] = '\0';
|
|
|
-
|
|
|
+ Payload[c] = '\0';*/
|
|
|
+ sprintf(Payload, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 2)));
|
|
|
|
|
|
|
|
|
- if(hashmap_operation(1, UniqueId, key_value) == TRUE)
|
|
|
+ if(hashmap_operation(HASH_OP_GET, UniqueId, key_value) == TRUE)
|
|
|
{
|
|
|
- hashmap_operation(2, UniqueId, key_value);
|
|
|
+ hashmap_operation(HASH_OP_REMOVE, UniqueId, key_value);
|
|
|
char * const testdup = strdup(key_value);
|
|
|
|
|
|
|
|
@@ -219,7 +225,7 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
|
|
|
case MESSAGE_TYPE_CALLERROR:
|
|
|
|
|
|
-
|
|
|
+
|
|
|
c = 0;
|
|
|
while (tempin[4+4+strlen(UniqueId)-1+c] != '\"')
|
|
|
{
|
|
@@ -227,10 +233,11 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
|
|
|
c++;
|
|
|
}
|
|
|
- ErrorCode[c] = '\0';
|
|
|
+ ErrorCode[c] = '\0';*/
|
|
|
|
|
|
+ sprintf(ErrorCode, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 2)));
|
|
|
|
|
|
-
|
|
|
+
|
|
|
c = 0;
|
|
|
while (tempin[4+4+4+strlen(UniqueId)-1+strlen(ErrorCode)-1+c] != '\"')
|
|
|
{
|
|
@@ -238,11 +245,12 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
|
|
|
c++;
|
|
|
}
|
|
|
- ErrorDescription[c] = '\0';
|
|
|
+ ErrorDescription[c] = '\0';*/
|
|
|
+ sprintf(ErrorDescription, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 3)));
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
c = 0;
|
|
|
templen= 4+4+4+3+strlen(UniqueId)-1+strlen(ErrorCode)-1+strlen(ErrorDescription)-1;
|
|
|
while ((c+ templen) < (strlen(tempin)-1))
|
|
@@ -251,15 +259,15 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
|
|
|
c++;
|
|
|
}
|
|
|
- Payload[c] = '\0';
|
|
|
-
|
|
|
+ Payload[c] = '\0';*/
|
|
|
+ sprintf(Payload, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 4)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- if(hashmap_operation(1, UniqueId, key_value) == TRUE)
|
|
|
+ if(hashmap_operation(HASH_OP_GET, UniqueId, key_value) == TRUE)
|
|
|
{
|
|
|
- hashmap_operation(2, UniqueId, key_value);
|
|
|
+ hashmap_operation(HASH_OP_REMOVE, UniqueId, key_value);
|
|
|
|
|
|
sprintf(Action, "%s", key_value);
|
|
|
|
|
@@ -277,7 +285,6 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
{
|
|
|
printf("Message is null. cant parse messgae. \n");
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
int CallHandler(char *uuid, char *str1,char *payload)
|