Browse Source

inserir response de login corretamente. Reconectar asterisk

pull/1/head
Rodgger 2 years ago
parent
commit
f8d07f2f2c
  1. 2
      Makefile
  2. 7
      src/net.c
  3. 9
      src/parse_action.c

2
Makefile

@ -7,7 +7,7 @@ NAME_LIBRARY=libami_c.so
DIR_OBJ=obj/
DIR_SRC=src/
IR_SRC=src/
CFLAGS =
CFLAGS = -g
OBJ=\

7
src/net.c

@ -48,6 +48,12 @@ void *ami_net(void *void_ami){
while(1){
if(ami->net.sock == -1){
ami_create_socket(&ami->net);
usleep(10000);
continue;
}
if(ami->net.is_connected == 0){
ami_connect_ami(&ami->net);
}
@ -90,6 +96,7 @@ void ami_connect_down(NET *net){
net->is_connected = 0;
net->imcomplete_net = 0;
ami_sock_close(net->sock);
net->sock = -1;
}

9
src/parse_action.c

@ -49,7 +49,7 @@ void parse_response(AMI *ami, const char *buffer, int *incomplete){
arg->key = (char *) calloc(1, len + 1);
strncpy(arg->key, buffer, len);
buffer = buffer + len + 2;
// action command
if(!strcmp(arg->key, "Output")){
size_t len = strlen(buffer);
@ -103,7 +103,10 @@ void parse_response(AMI *ami, const char *buffer, int *incomplete){
RESPONSE *login = ami_response_create();
memcpy(login, p_action->response, sizeof(RESPONSE));
ami_action_free(p_action);
// ami_action_free(p_action);
free( p_action->actionid );
ami_event_free(p_action->events);
free( p_action );
if(ami->asterisk.response_login){
ami_response_free( ami->asterisk.response_login );
}
@ -112,10 +115,8 @@ void parse_response(AMI *ami, const char *buffer, int *incomplete){
return;
}
ami_action_add( &ami->actions, p_action );
pthread_mutex_unlock(&ami->thread.mutex_actions);
}

Loading…
Cancel
Save