Commit 67ab731c authored by jehan's avatar jehan

add channel listener to channel created by socket server

parent 3fbf74e5
......@@ -36,12 +36,14 @@ static void belle_sip_listening_point_uninit(belle_sip_listening_point_t *lp){
,belle_sip_uri_get_host(BELLE_SIP_LISTENING_POINT(lp)->listening_uri)
,belle_sip_uri_get_port(BELLE_SIP_LISTENING_POINT(lp)->listening_uri));
belle_sip_object_unref(lp->listening_uri);
lp->channel_listener=NULL; /*does not unref provider*/
belle_sip_uninit_sockets();
belle_sip_listening_point_set_keep_alive(lp,-1);
}
void belle_sip_listening_point_add_channel(belle_sip_listening_point_t *lp, belle_sip_channel_t *chan){
belle_sip_channel_add_listener(chan,lp->channel_listener); /*add channel listener*/
lp->channels=belle_sip_list_append(lp->channels,chan);/*channel is already owned*/
}
......@@ -56,6 +58,7 @@ belle_sip_channel_t *belle_sip_listening_point_create_channel(belle_sip_listenin
void belle_sip_listening_point_remove_channel(belle_sip_listening_point_t *lp, belle_sip_channel_t *chan){
belle_sip_channel_remove_listener(chan,lp->channel_listener);
lp->channels=belle_sip_list_remove(lp->channels,chan);
belle_sip_object_unref(chan);
}
......@@ -204,3 +207,6 @@ int belle_sip_listening_point_get_keep_alive(const belle_sip_listening_point_t *
return lp->keep_alive_timer?belle_sip_source_get_timeout(lp->keep_alive_timer):-1;
}
void belle_sip_listener_set_channel_listener(belle_sip_listening_point_t *lp,belle_sip_channel_listener_t* channel_listener) {
lp->channel_listener=channel_listener;
}
......@@ -42,6 +42,7 @@ struct belle_sip_listening_point{
belle_sip_list_t *channels;
belle_sip_uri_t* listening_uri;
belle_sip_source_t* keep_alive_timer;
belle_sip_channel_listener_t* channel_listener; /*initial channel listener used for channel creation, specially for socket server*/
};
void belle_sip_listening_point_init(belle_sip_listening_point_t *lp, belle_sip_stack_t *s, const char *address, int port);
......@@ -51,6 +52,7 @@ void belle_sip_listening_point_remove_channel(belle_sip_listening_point_t *lp, b
int belle_sip_listening_point_get_well_known_port(const char *transport);
belle_sip_channel_t *belle_sip_listening_point_get_channel(belle_sip_listening_point_t *lp,const char *peer_name, int peer_port);
void belle_sip_listening_point_add_channel(belle_sip_listening_point_t *lp, belle_sip_channel_t *chan);
void belle_sip_listener_set_channel_listener(belle_sip_listening_point_t *lp,belle_sip_channel_listener_t* channel_listener);
/**udp*/
typedef struct belle_sip_udp_listening_point belle_sip_udp_listening_point_t;
......
......@@ -284,6 +284,7 @@ int belle_sip_provider_add_listening_point(belle_sip_provider_t *p, belle_sip_li
belle_sip_error("Cannot add NULL lp to provider [%p]",p);
return -1;
}
belle_sip_listener_set_channel_listener(lp,BELLE_SIP_CHANNEL_LISTENER(p));
p->lps=belle_sip_list_append(p->lps,belle_sip_object_ref(lp));
return 0;
}
......@@ -475,8 +476,7 @@ belle_sip_channel_t * belle_sip_provider_get_channel(belle_sip_provider_t *p, co
}
if (candidate){
chan=belle_sip_listening_point_create_channel(candidate,name,port);
if (chan) belle_sip_channel_add_listener(chan,(belle_sip_channel_listener_t*)p);
else belle_sip_error("Could not create channel to %s:%s:%i",transport,name,port);
if (!chan) belle_sip_error("Could not create channel to %s:%s:%i",transport,name,port);
return chan;
}
belle_sip_error("No listening point matching for transport %s",transport);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment