|
@@ -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;
|
|
|
+ //int c = 0;
|
|
|
+ //int templen = 0;
|
|
|
char key_value[VALUE_MAX_LENGTH];
|
|
|
|
|
|
//parsing received message and do something
|
|
@@ -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)));
|
|
|
+
|
|
|
//char *str = "[ ]";
|
|
|
if(strcmp((const char *)tempin,"[ ]") == 0)
|
|
|
{
|
|
@@ -121,22 +125,23 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
|
|
|
if(tempin[0] != '\0')//if(jobj != NULL)
|
|
|
{
|
|
|
- MsgType = tempin[1] - '0';
|
|
|
+ //MsgType = tempin[1] - '0';
|
|
|
//printf("MsgType=%d\n",MsgType);
|
|
|
- c = 0;
|
|
|
+ //c = 0;
|
|
|
|
|
|
if((MsgType != 2) && (MsgType != 3) && (MsgType != 4) )
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
while ((tempin[4+c] != '\"') && (tempin[4+c] != '\0'))
|
|
|
{
|
|
|
UniqueId[c] = tempin[4+c];
|
|
|
//printf("i=%d UniqueId[c]=%c\n",c, UniqueId[c]);
|
|
|
c++;
|
|
|
}
|
|
|
- UniqueId[c] = '\0';
|
|
|
+ UniqueId[c] = '\0';*/
|
|
|
//printf("UniqueId=%s\n",UniqueId);
|
|
|
|
|
|
if(UniqueId[0] == '\0')
|
|
@@ -150,7 +155,7 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
{
|
|
|
case MESSAGE_TYPE_CALL:
|
|
|
//DEBUG_INFO("MESSAGE_TYPE_CALL\n");
|
|
|
-
|
|
|
+ /*
|
|
|
c = 0;
|
|
|
while (tempin[4+4+strlen(UniqueId)-1+c] != '\"')
|
|
|
{
|
|
@@ -158,10 +163,10 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
//printf("i=%d Action[c]=%c\n",c, Action[c]);
|
|
|
c++;
|
|
|
}
|
|
|
- Action[c] = '\0';
|
|
|
-
|
|
|
+ Action[c] = '\0';*/
|
|
|
+ sprintf(Action, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 2)));
|
|
|
//printf("Action=%s\n",Action);
|
|
|
-
|
|
|
+ /*
|
|
|
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)
|
|
|
//printf("i=%d Payload[c]=%c\n",c, Payload[c]);
|
|
|
c++;
|
|
|
}
|
|
|
- Payload[c] = '\0';
|
|
|
- //printf("Payload=%s\n",Payload);
|
|
|
+ Payload[c] = '\0';*/
|
|
|
|
|
|
+ //printf("Payload=%s\n",Payload);
|
|
|
+ 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)
|
|
|
//printf("i=%d sstr=%c\n",c, Payload[c]);
|
|
|
c++;
|
|
|
}
|
|
|
- Payload[c] = '\0';
|
|
|
-
|
|
|
+ Payload[c] = '\0';*/
|
|
|
+ sprintf(Payload, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 2)));
|
|
|
//printf("Payload=%s\n",Payload);
|
|
|
|
|
|
- if(hashmap_operation(1, UniqueId, key_value) == TRUE)//if(hashmap_operation(1,NULL/*hashMap*/, UniqueId, mapItem, key_value/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_get(hashMap, UniqueId, (void**)(&mapItem)) == MAP_OK*/)
|
|
|
+ if(hashmap_operation(HASH_OP_GET, UniqueId, key_value) == TRUE)//if(hashmap_operation(1,NULL/*hashMap*/, UniqueId, mapItem, key_value/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_get(hashMap, UniqueId, (void**)(&mapItem)) == MAP_OK*/)
|
|
|
{
|
|
|
- hashmap_operation(2, UniqueId, key_value);//hashmap_operation(2,NULL/*hashMap*/, UniqueId, mapItem, key_value/*(void**)(&mapItem)*/);//hashmap_remove(hashMap, UniqueId);
|
|
|
+ hashmap_operation(HASH_OP_REMOVE, UniqueId, key_value);//hashmap_operation(2,NULL/*hashMap*/, UniqueId, mapItem, key_value/*(void**)(&mapItem)*/);//hashmap_remove(hashMap, UniqueId);
|
|
|
char * const testdup = strdup(key_value/*mapItem->key_value*/);
|
|
|
|
|
|
//printf("original string: %s (@%p)\n", testdup, testdup);
|
|
@@ -219,7 +225,7 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
|
|
|
case MESSAGE_TYPE_CALLERROR:
|
|
|
//DEBUG_INFO("MESSAGE_TYPE_CALLERROR\n");
|
|
|
-
|
|
|
+ /*
|
|
|
c = 0;
|
|
|
while (tempin[4+4+strlen(UniqueId)-1+c] != '\"')
|
|
|
{
|
|
@@ -227,10 +233,11 @@ void ReceivedMessage(void *in, size_t len)
|
|
|
// printf("i=%d sstr=%c\n",c, ErrorCode[c]);
|
|
|
c++;
|
|
|
}
|
|
|
- ErrorCode[c] = '\0';
|
|
|
+ ErrorCode[c] = '\0';*/
|
|
|
|
|
|
+ sprintf(ErrorCode, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 2)));
|
|
|
// DEBUG_INFO("ErrorCode=%s\n",ErrorCode);
|
|
|
-
|
|
|
+ /*
|
|
|
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)
|
|
|
//printf("i=%d sstr=%c\n",c, ErrorDescription[c]);
|
|
|
c++;
|
|
|
}
|
|
|
- ErrorDescription[c] = '\0';
|
|
|
+ ErrorDescription[c] = '\0';*/
|
|
|
+ sprintf(ErrorDescription, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 3)));
|
|
|
|
|
|
// DEBUG_INFO("ErrorDescription=%s\n",ErrorDescription);
|
|
|
|
|
|
-
|
|
|
+ /*
|
|
|
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)
|
|
|
// printf("i=%d sstr=%c\n",c, Payload[c]);
|
|
|
c++;
|
|
|
}
|
|
|
- Payload[c] = '\0';
|
|
|
-
|
|
|
+ Payload[c] = '\0';*/
|
|
|
+ sprintf(Payload, "%s", json_object_get_string(json_object_array_get_idx(json_tokener_parse(tempin), 4)));
|
|
|
// DEBUG_INFO("Payload=%s\n",Payload);
|
|
|
|
|
|
|
|
|
|
|
|
- if(hashmap_operation(1, UniqueId, key_value) == TRUE)//if(hashmap_operation(1,NULL/*hashMap*/, UniqueId, mapItem, key_value/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_get(hashMap, UniqueId, (void**)(&mapItem)) == MAP_OK*/)
|
|
|
+ if(hashmap_operation(HASH_OP_GET, UniqueId, key_value) == TRUE)//if(hashmap_operation(1,NULL/*hashMap*/, UniqueId, mapItem, key_value/*(void**)(&mapItem)*/) == MAP_OK/*hashmap_get(hashMap, UniqueId, (void**)(&mapItem)) == MAP_OK*/)
|
|
|
{
|
|
|
- hashmap_operation(2, UniqueId, key_value);//hashmap_operation(2,NULL/*hashMap*/, UniqueId, mapItem, key_value/*(void**)(&mapItem)*/);//hashmap_remove(hashMap, UniqueId);
|
|
|
+ hashmap_operation(HASH_OP_REMOVE, UniqueId, key_value);//hashmap_operation(2,NULL/*hashMap*/, UniqueId, mapItem, key_value/*(void**)(&mapItem)*/);//hashmap_remove(hashMap, UniqueId);
|
|
|
|
|
|
sprintf(Action, "%s", key_value/*mapItem->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)
|