From 0b18987f9e5654d0dd0d589c19b05f5304ff8ac0 Mon Sep 17 00:00:00 2001 From: Giovanni Maruzzelli Date: Sat, 6 Jun 2009 16:36:26 +0000 Subject: [PATCH] skypiax: when repeatedly you try to connect to non-existing Skype account in a short period, the Skype client send you back the two halves of the message 'ERROR 92 CALL: Unrecognised identity' inverted in a way that breaks the flux of the API messages. Maybe an anti-spam feature? Anyway, let's try to work around it and restore sanity with a 1 second delay git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13663 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- .../endpoints/mod_skypiax/skypiax_protocol.c | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/mod/endpoints/mod_skypiax/skypiax_protocol.c b/src/mod/endpoints/mod_skypiax/skypiax_protocol.c index 55dd5afeb0..ee0285f033 100644 --- a/src/mod/endpoints/mod_skypiax/skypiax_protocol.c +++ b/src/mod/endpoints/mod_skypiax/skypiax_protocol.c @@ -1448,6 +1448,9 @@ void *skypiax_do_skypeapi_thread_func(void *obj) char buffer[17000]; char *b; int i; + int continue_is_broken=0; + Atom atom_begin = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False); + Atom atom_continue = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False); b = buffer; @@ -1466,15 +1469,38 @@ void *skypiax_do_skypeapi_thread_func(void *obj) buf[i] = '\0'; + if(an_event.xclient.message_type == atom_begin){ + + if(strlen(buffer)){ + unsigned int howmany; + howmany = strlen(b) + 1; + howmany = write(SkypiaxHandles->fdesc[1], b, howmany); + DEBUGA_SKYPE ("RECEIVED2=|||%s|||\n", SKYPIAX_P_LOG, buffer); + memset(buffer, '\0', 17000); + } + } + if(an_event.xclient.message_type == atom_continue){ + + if(!strlen(buffer)){ + WARNINGA("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||. Let's introduce a 1 second delay.\n", SKYPIAX_P_LOG, buf); + continue_is_broken=1; + skypiax_sleep(1000000); //1 sec + break; + } + } + strcat(buffer, buf); - if (i < 20) { /* last fragment */ + if (i < 20 || continue_is_broken) { /* last fragment */ unsigned int howmany; howmany = strlen(b) + 1; howmany = write(SkypiaxHandles->fdesc[1], b, howmany); + DEBUGA_SKYPE ("RECEIVED=|||%s|||\n", SKYPIAX_P_LOG, buffer); memset(buffer, '\0', 17000); + XFlush(disp); + continue_is_broken=0; } break;