This repository was archived by the owner on Dec 4, 2017. It is now read-only.
forked from mixedpuppy/socialapi-demo
-
Notifications
You must be signed in to change notification settings - Fork 10
Reject calls when already in a call on mobile #37
Open
tOkeshu
wants to merge
7
commits into
mozilla:master
Choose a base branch
from
tOkeshu:mobile-auto-reject
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
bcd7742
Reject calls when already in a call on mobile
minitrope efce9b8
Improve the UI for status messages
minitrope 8941a60
Fix coding style
minitrope de7f800
Remove the state parameter from setStatus
minitrope f9e4c81
Fix coding style
minitrope 43984a1
Merge branch 'master' into mobile-auto-reject
minitrope 6e73a6f
Add meaningful message when closing/rejecting/canceling the call
minitrope File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ var gContacts = {}; | |
| var gChats = {}; | ||
| var gUsername = ""; | ||
| var gFake = false; | ||
| var gInChat = false; | ||
|
|
||
| function onPersonaLogin(assertion) { | ||
| $("#guest").hide(); | ||
|
|
@@ -46,12 +47,11 @@ function callPerson(aPerson, aAudioCall) { | |
| } | ||
|
|
||
| openChat(aPerson, function(aWin) { | ||
| var win = gChats[aPerson].win; | ||
| var doc = win.document; | ||
| doc.getElementById("calling").style.display = "block"; | ||
| gChats[aPerson].pc = webrtcMedia.startCall(aPerson, win, aAudioCall, | ||
| onConnection, setupFileSharing); | ||
| gChats[aPerson].audioOnly = aAudioCall; | ||
| var chat = gChats[aPerson]; | ||
| setStatus(chat, "Calling..."); | ||
| chat.pc = webrtcMedia.startCall(aPerson, chat.win, aAudioCall, | ||
| onConnection, setupFileSharing); | ||
| chat.audioOnly = aAudioCall; | ||
| }); | ||
| } | ||
|
|
||
|
|
@@ -316,9 +316,11 @@ function setupEventSource() { | |
|
|
||
| doc.getElementById("callAnswer").style.display = "block"; | ||
| doc.getElementById("reject").onclick = function() { | ||
| stopCall(from, "The call has been rejected"); | ||
| win.close(); | ||
| }; | ||
| doc.getElementById("accept").onclick = function() { | ||
| gInChat = true; | ||
| doc.getElementById("callAnswer").style.display = "none"; | ||
| gChats[from].pc = webrtcMedia.handleOffer(data, win, gChats[from].audioOnly, | ||
| onConnection, setupFileSharing); | ||
|
|
@@ -340,8 +342,9 @@ function setupEventSource() { | |
| audio.mozSrcObject = video.mozSrcObject; | ||
| video.mozSrcObject = null; | ||
| } | ||
| chat.win.document.getElementById("calling").style.display = "none"; | ||
| setStatus(chat, ""); | ||
| pc.setRemoteDescription(answer, function() { | ||
| gInChat = true; | ||
| // Nothing to do for the audio/video. The interesting things for | ||
| // them will happen in onaddstream. | ||
| // We need to establish the data connection though. | ||
|
|
@@ -363,8 +366,12 @@ function setupEventSource() { | |
| return; | ||
| } | ||
| webrtcMedia.endCall(chat.pc, chat.dc, chat.win, chat.audioOnly); | ||
| delete gChats[data.from]; | ||
| chat.win.close(); | ||
| setStatus(chat, data.reason || "The call has been closed."); | ||
| chat.win.document.getElementById("callAnswer").style.display = "none"; | ||
| setTimeout(function() { | ||
| chat.win.close(); | ||
| delete gChats[data.from]; | ||
| }, 10000); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This timer needs to be cancelled when the user closes the floating window by hand. Otherwise, it may execute if the user starts another call with the same contact; that's what caused the bug I mentioned at #37 (comment) |
||
| }); | ||
|
|
||
| window.addEventListener("beforeunload", function() { | ||
|
|
@@ -373,6 +380,15 @@ function setupEventSource() { | |
| }, true); | ||
| } | ||
|
|
||
| function setStatus(chat, message) { | ||
| var status = chat.win.document.getElementById("status"); | ||
| if (message) { | ||
| status.textContent = message; | ||
| status.style.display = "block"; | ||
| } else | ||
| status.style.display = "none"; | ||
| } | ||
|
|
||
| function userIsConnected(userdata) { | ||
| $("#userid").text(userdata.userName); | ||
| $("#usericon").attr("src", userdata.portrait); | ||
|
|
@@ -426,10 +442,11 @@ function openChat(aTarget, aCallback) { | |
| win.addEventListener("unload", function() { | ||
| if (!(aTarget in gChats)) | ||
| return; | ||
| stopCall(aTarget); | ||
| stopCall(aTarget, gInChat ? "" : "The call has been canceled."); | ||
| var chat = gChats[aTarget]; | ||
| webrtcMedia.endCall(chat.pc, chat.dc, chat.win, chat.audioOnly); | ||
| delete gChats[aTarget]; | ||
| gInChat = false; | ||
| }); | ||
| if (aCallback) { | ||
| aCallback(win); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need the audioOnly variable in here, so maybe move that test and early return just after the "var data = " ... line?