This might sound silly, but I have been searching for a very long time on how to do that, and all what I get is only being more confused :/ I have made a webRTC video chat application and it is working just fine, what I need now is how to ring one android-device from another when that other wants to call first one, I mean until now I must enter the same room name on both devices to be able to make a video call and that's not practical cuz in real life how will the other peer or device user know that someone wants to call him, I have read about SIP, but it seems not what I am looking for, please help.
2 Answers
WebRTC
is responsible for PeerConnection
Not ring the device and handle the Users . Its your own data you need to Handle it yourself .
Thats where SignalingServer
Comes to the party . Once youcreateOffer()
from a userId(lets say id is 2)
and send it to your Singnalling server with the destination userSocketId(Here i am mapping userId to SocketId you can also map some other field).
If destination Socket has registered it will immediately get the incoming call request with caller info which you have put in the packet
. Then you can Ring the device .
See i can not explain the whole functions here but one thing you should understand You will have to utilize Signalling server
for textual data sharing beetween two devices.
Basically you need to have the ID
to which you want to call then only signalling server will emit the Particular data on receiver end. So you need a cloud database in which all user info is saved .
You can follow Sample mentioned here. The signalling server
in this sample uses NODE.JS
which is easy to understand and modify if you are familiar with java.
Edit:- If you are looking for the point where you should start RING
. Well it should ring whenever you receive an Offer
and you open your calling UI(Activity).
Keep one thing in Mind ICECandiates
should not get lost so Use proper handshake bettween both party before sending ICECandiates
lists cause this is the base of setting up PeerConnection
.
public void startCallNotification() {
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
ringtone = RingtoneManager.getRingtone(this, notification);
ringtone.play();
vibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
long[] vibrationCycle = {0, 1000, 1000};
if (vibrator.hasVibrator()) {
vibrator.vibrate(vibrationCycle, 1);
}
}
Just call the method above whenever you get an offer. Obviously you need to handle some other cases like internet lost on caller end and connection reset, Wait for ICECandidates.
Things will bread and butter if you understand WebRTC
architecture first. SO i humbly recommend to read the structure first. You can start with This and This or similar blogs on WEBRTC
.

- 20,406
- 11
- 52
- 83
-
1first of all thank u, but I need to ask more about something, first I am already using the same Signalling Server u r attaching to get the socket io setup and same code in android also in the thread u r attaching and I totally aware of the fact that webRTC has nothing to do with the call ringing, u r talking about that signalling is where I should use to make the phone ring, correct, please tell me how, and thanks again for ur answer @ADM – Mohammad Elsayed Jun 10 '18 at 06:28
-
will this start if the 1. is on foreground (I am sure yes) 2. on background 3. neither in foreground nor in background – Mohammad Elsayed Jun 10 '18 at 16:24
-
Its depend upon API level . Due to background restrictions you can not maintain a socket connection in background . So you need to depend upon FCM notifications messages. – ADM Jun 10 '18 at 16:39
-
If it won't disappoint u, I am developing this app for a smart glasses that does not support any of google play services, any other solutions u can recommend. – Mohammad Elsayed Jun 10 '18 at 20:31
-
Sorry i can't . I do not have much idea about smart glass development. You should ask a new question about it . Cause this question is already too broad . Break things apart and find out the need. I think the need here is a background service . Do research and if you stuck then ask on SO with effort . – ADM Jun 11 '18 at 14:58
-
the question has nothing to do with the smart glasses, the smart glasses is just a very normal android device which only difference from android phone is that it can't use any of google play services – Mohammad Elsayed Jun 12 '18 at 01:00
-
1That's what I am saying . No play services no push notifications . So there must be a way to notify the device for an event . For me it's just black box . I haven't worked on wearable device too . So I do not have any idea about that . If you understand the underlying architecture of webrtc then the only problem you left with is how to achieve this in glass . You can add a new question for this . Cause I smell a bounty on this topic xd. – ADM Jun 12 '18 at 11:15
Just Use Socket.io which consists of two parts: 1. Frontend SDK (IOS, Android, Web, ...etc) 2. Backend -> very well documented
Here is the link: https://socket.io/

- 1,885
- 1
- 20
- 46