Skip to content

Commit

Permalink
Fix bug about race condition in room call
Browse files Browse the repository at this point in the history
  • Loading branch information
DengQiming committed Feb 13, 2018
1 parent 75a8ec8 commit adaabc5
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import com.cisco.spark.android.locus.events.RetrofitErrorEvent;
import com.cisco.spark.android.locus.events.ParticipantRoomDeclinedEvent;
import com.cisco.spark.android.locus.events.ParticipantSelfChangedEvent;
import com.cisco.spark.android.locus.model.Locus;
import com.cisco.spark.android.locus.model.LocusData;
import com.cisco.spark.android.locus.model.LocusKey;
import com.cisco.spark.android.locus.model.LocusParticipantDevice;
Expand Down Expand Up @@ -825,9 +826,10 @@ public void onEventMainThread(CallNotificationEvent event) {
public void onEventMainThread(ParticipantSelfChangedEvent event) {
Ln.i("ParticipantSelfChangedEvent is received " + event.getLocusKey());
CallImpl call = _calls.get(event.getLocusKey());
if (call != null && event.getLocus() != null
&& event.getLocus().getSelf().getDevices() != null) {
List deviceList = event.getLocus().getSelf().getDevices();
Locus locus = _callControlService.getLocus(event.getLocusKey());
if (call != null && locus != null
&& locus.getSelf().getDevices() != null) {
List deviceList = locus.getSelf().getDevices();
if (call.getStatus() == Call.CallStatus.CONNECTED && !isJoinedFromThisDevice(deviceList)) {
Ln.d("Local device left locusKey: " + event.getLocusKey());
if (call.getHangupCallback() != null) {
Expand All @@ -837,18 +839,18 @@ public void onEventMainThread(ParticipantSelfChangedEvent event) {
} else if (call.getStatus() != Call.CallStatus.CONNECTED
&& isJoinedFromOtherDevice(deviceList)
&& !isJoinedFromThisDevice(deviceList)) {
com.cisco.spark.android.callcontrol.model.Call locus = _callControlService.getCall(event.getLocusKey());
if (locus == null || !locus.isActive()) {
com.cisco.spark.android.callcontrol.model.Call _call = _callControlService.getCall(event.getLocusKey());
if (_call == null || !_call.isActive()) {
Ln.d("other device connected locusKey: " + event.getLocusKey());
_removeCall(new CallObserver.OtherConnected(call));
}else{
Ln.d("Self device has already connected, ignore other device connect");
}
} else if (call.getStatus() != Call.CallStatus.CONNECTED
&& !isJoinedFromThisDevice(deviceList)
&& event.getLocus().getSelf().getState() == LocusParticipant.State.DECLINED) {
com.cisco.spark.android.callcontrol.model.Call locus = _callControlService.getCall(event.getLocusKey());
if (locus == null || !locus.isActive()) {
&& locus.getSelf().getState() == LocusParticipant.State.DECLINED) {
com.cisco.spark.android.callcontrol.model.Call _call = _callControlService.getCall(event.getLocusKey());
if (_call == null || !_call.isActive()) {
Ln.d("other device declined locusKey: " + event.getLocusKey());
_removeCall(new CallObserver.OtherDeclined(call));
}else{
Expand Down

0 comments on commit adaabc5

Please sign in to comment.