diff --git a/include/wb_xmpp_wf.h b/include/wb_xmpp_wf.h index 52f0b332..8b8ee469 100644 --- a/include/wb_xmpp_wf.h +++ b/include/wb_xmpp_wf.h @@ -38,7 +38,7 @@ void xmpp_iq_create_profile(void); void xmpp_iq_confirm_notification(const char *notif); void xmpp_iq_get_account_profiles(void); void xmpp_iq_get_master_server(const char *channel); -void xmpp_iq_join_channel(void); +void xmpp_iq_join_channel(const char *channel); void xmpp_iq_peer_status_update(const char *to_jid); void xmpp_promote_room_master(const char *nickname); void xmpp_iq_player_status(int status); diff --git a/src/xmpp_wf/get/xmpp_iq_get_account_profiles.c b/src/xmpp_wf/get/xmpp_iq_get_account_profiles.c index 7ae92b4f..e678df0d 100644 --- a/src/xmpp_wf/get/xmpp_iq_get_account_profiles.c +++ b/src/xmpp_wf/get/xmpp_iq_get_account_profiles.c @@ -45,7 +45,7 @@ static void xmpp_iq_get_account_profiles_cb(const char *msg) if (!session.profile_id) xmpp_iq_create_profile(); else - xmpp_iq_join_channel(); + xmpp_iq_join_channel(NULL); } void xmpp_iq_get_account_profiles(void) diff --git a/src/xmpp_wf/get/xmpp_iq_join_channel.c b/src/xmpp_wf/get/xmpp_iq_join_channel.c index e09bb1ca..a5a0b99d 100644 --- a/src/xmpp_wf/get/xmpp_iq_join_channel.c +++ b/src/xmpp_wf/get/xmpp_iq_join_channel.c @@ -71,23 +71,30 @@ static void xmpp_iq_join_channel_cb(const char *msg) xmpp_iq_player_status(STATUS_ONLINE | STATUS_LOBBY); } -void xmpp_iq_join_channel(void) +void xmpp_iq_join_channel(const char *channel) { + int is_switch = session.channel != NULL; t_uid id; idh_generate_unique_id(&id); idh_register(&id, xmpp_iq_join_channel_cb, 0); + if (channel != NULL) + { + free(session.channel); + session.channel = strdup(channel); + } + /* Join CryOnline channel */ send_stream_format(session.wfs, "" "" - "" "" "", - &id, + &id, is_switch ? "switch" : "join", session.active_token, session.profile_id, session.online_id, session.channel); } diff --git a/src/xmpp_wf/result/xmpp_iq_invitation_request.c b/src/xmpp_wf/result/xmpp_iq_invitation_request.c index 3aa696e1..ef9bd44b 100644 --- a/src/xmpp_wf/result/xmpp_iq_invitation_request.c +++ b/src/xmpp_wf/result/xmpp_iq_invitation_request.c @@ -50,21 +50,7 @@ static void xmpp_iq_invitation_request_cb(const char *msg_id, const char *msg) { /* 1. Change channel if invitation was not on the same server */ if (strcmp(session.channel, resource)) - { - send_stream_format(session.wfs, - "" - "" - "" - "" - "", - session.active_token, session.profile_id, - session.online_id, resource); - } + xmpp_iq_join_channel(resource); /* 2. Confirm invitation */ send_stream_format(session.wfs, @@ -91,9 +77,7 @@ static void xmpp_iq_invitation_request_cb(const char *msg_id, const char *msg) free(server); free(ticket); free(room); - - free(session.channel); - session.channel = resource; + free(resource); free(session.group_id); session.group_id = group;