Skip to content

Commit 313a698

Browse files
committed
Fixes #98: When a wrong user name is used in Messenger settings we enter an endless loop of failed registrations. Fixes #93: Update Hello World sample App so that it properly uses webrtc
1 parent 298eed4 commit 313a698

File tree

7 files changed

+29
-8
lines changed

7 files changed

+29
-8
lines changed

Examples/restcomm-helloworld/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<application
66
android:allowBackup="true"
7-
android:icon="@mipmap/ic_launcher"
7+
android:icon="@drawable/icon_144x144"
88
android:label="@string/app_name"
99
android:theme="@style/AppTheme" >
1010
<activity

Examples/restcomm-helloworld/app/src/main/java/com/telestax/restcomm_helloworld/MainActivity.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public void onError(Exception exception)
5858
// TODO: we don't support capability tokens yet so let's use an empty string
5959
device = RCClient.createDevice("", this);
6060
Intent intent = new Intent(getApplicationContext(), MainActivity.class);
61-
device.setIncomingIntent(intent);
61+
// we don't have a separate activity for the calls, so use the same intent both for calls and messages
62+
device.setPendingIntents(intent, intent);
6263

6364
connection = null;
6465

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.so

Examples/restcomm-helloworld/app/src/main/jniLibs/armeabi-v7a/.keep

Whitespace-only changes.
6.01 KB
Loading

Examples/restcomm-messenger/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ android {
99
minSdkVersion 17
1010
targetSdkVersion 22
1111
versionCode 1
12-
versionName "1.2.2"
12+
versionName "1.2.3"
1313
}
1414
buildTypes {
1515
release {

sipua/src/main/java/org/mobicents/restcomm/android/sipua/impl/SipManager.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import android.javax.sip.address.Address;
5454
import android.javax.sip.address.AddressFactory;
5555
import android.javax.sip.header.CSeqHeader;
56+
import android.javax.sip.header.CallIdHeader;
5657
import android.javax.sip.header.ContactHeader;
5758
import android.javax.sip.header.ContentTypeHeader;
5859
import android.javax.sip.header.HeaderFactory;
@@ -91,6 +92,8 @@ enum CallDirection {
9192
private HashMap<String,String> customHeaders;
9293
private ClientTransaction currentClientTransaction = null;
9394
private ServerTransaction currentServerTransaction;
95+
private static final int MAX_REGISTER_ATTEMPTS = 3;
96+
HashMap<String, Integer> registerAuthenticationMap = new HashMap<>();
9497
public int ackCount = 0;
9598
DigestServerAuthenticationHelper dsam;
9699
// Is it an outgoing call or incoming call. We're using this so that when we hit
@@ -501,10 +504,21 @@ public void processResponse(ResponseEvent arg0) {
501504
sipProfile.getRemoteIp(), sipProfile
502505
.getSipPassword()), headerFactory);
503506
try {
504-
ClientTransaction inviteTid = authenticationHelper
505-
.handleChallenge(response, tid, sipProvider, 5, true);
506-
currentClientTransaction = inviteTid;
507-
inviteTid.sendRequest();
507+
CallIdHeader callId = (CallIdHeader)response.getHeader("Call-ID"); //responseDialog.getCallId();
508+
int attempts = 0;
509+
if (registerAuthenticationMap.containsKey(callId.toString())) {
510+
attempts = registerAuthenticationMap.get(callId.toString()).intValue();
511+
}
512+
513+
// we 're subtracting one since the first attempt has already taken place
514+
// (that way we are enforcing MAX_REGISTER_ATTEMPTS at most)
515+
if (attempts < MAX_REGISTER_ATTEMPTS - 1) {
516+
ClientTransaction inviteTid = authenticationHelper
517+
.handleChallenge(response, tid, sipProvider, 5, true);
518+
currentClientTransaction = inviteTid;
519+
inviteTid.sendRequest();
520+
registerAuthenticationMap.put(callId.toString(), attempts + 1);
521+
}
508522
} catch (NullPointerException e) {
509523
e.printStackTrace();
510524
} catch (SipException e) {
@@ -544,7 +558,12 @@ public void processResponse(ResponseEvent arg0) {
544558
e.printStackTrace();
545559
}
546560

547-
} else if (cseq.getMethod().equals(Request.CANCEL)) {
561+
}
562+
else if (cseq.getMethod().equals(Request.REGISTER)) {
563+
// we got 200 OK to register request, clear the map
564+
registerAuthenticationMap.clear();
565+
}
566+
else if (cseq.getMethod().equals(Request.CANCEL)) {
548567
if (dialog.getState() == DialogState.CONFIRMED) {
549568
// oops cancel went in too late. Need to hang up the
550569
// dialog.

0 commit comments

Comments
 (0)