How to handle multiple peer connection and offline mode in webrtc? - webrtc

I have a few questions about the chat app I'm developing with webrtc. Suppose we have peers A, B, C, and D.
if peer A wants to message peer B via webrtc both have to be active and maintain a live connection. But in case one of peer is offline or the app is closed how would I handle this use case.
If a user opens a chat mobile app shall I create connection to all available peer immediately? Or when use enters someone chat window?
If user A is chatting with B via RTCDatachannel and C wants to message user A. So in this case shall terminate A's connection to B and open it with C? or how to handle this use case.
How group chatting can be handled using RTCDatachannel, I mean how I can let multiple users to connect to one another so as to multicast to each other.
I'll be grateful if anyone can guide me on this. All I'm trying is to make a peer-to-peer chat app using webrtc only text and media files are exchanged.

Related

How to always connect to socket.io even when shutdown or exit the application to be able to receive notifications from calls or messages(React Native)

I'm having a problem with react native
my app can let you video call each other using webRTC and socket.io, the technologies i use are WebRTC, React Native, Socket.io , socket.io-client, react-native-webrtc
Basically the way my app works is when you open the app you automatically connect to socket.io to listen and make calls but when I turn off the phone screen or exit the app I can't hear and receive calls can call again because at that time the socket has automatically disconnected.
I want my application can still work properly even if I exit the application my application can still receive notifications of incoming calls from another person, can say I want my application Works like Messenger App
My current workaround is to find a way for each user's socket to always be connected to listen for incoming calls from others.
Has anyone encountered this problem or have a solution for this please let me know, I really appreciate it
Thank you guys, Have a nice day <3
Move your socket to the Background service and then you can add the socket events in the service.
Note: This will increase your battery consumption.

VoIP App development in xamarin with Xmpp Server

I want to develop a VoIP app with Xamarin and Xmpp server.
So far the only things that I have found is the openfire and "jitsi meet" for the server side and matrix for the client side. But the matrix has nothing to do with voice streaming and is just for text messaging and "jitsi meet" doesn’t have any sdk for .net client side.
I also have found the red5pro but this has client sdks just for native android and ios development platform and has nothing for Mono.
So what Should I look for?!
First, let's clarify some basics:
openfire is a XMPP server. Basically, this is all you need on the server side for basic VoIP support.
Alternatives include ejabberd and Prosody.
jitsi meet essentialy already is a VoIP app, so if you want to develop your own, you don't really need that.
"Jitsi Videobridge" on the other hand can be used to provide a relay server for video conferences. For your first steps with a simple VoIP app, you wont need that either, but if you want your users to be able to create video conferences with many participants, then this helps.
(Explanation: Normally, when you create a P2P-Video conference, you
have two options: First, all users send their video data to all
participants (everybody needs lots of bandwidth), or you pick one
participant ("host") that receives the video streams of every
participant end sends them to every other participant. In the second
case, a normal participant only has to upload his stream once and
download n streams, whereas the host does most of the work - so only
that one user needs high bandwidth.
Jitsi Videobridge can run on a server and act as this conference host (usually a server has a much better bandwidth than a home user), so that none of the participants has to act as a host.
In simple VoIP applications (without video), this may not be neccessary, as audio streams are usually much smaller than video streams.)
Now, as I said above, in order to write a VoIP app, you basically only need a XMPP server (openfire, prosody and ejabberd should all be sufficient for this use case), a client library that supports Jingle and client libraries for the RTP media streams (transfer and display).
Jingle is the name of a XMPP protocol extension that enables the negotiation of P2P data streams as they are needed for a VoIP call.
The relevant protocol specifications:
XEP 0166: Jingle
XEP-0167: Jingle RTP Sessions
So what you need to find is a XMPP library with support for the jingle protocol. The C# Matrix XMPP SDK (not to be confused with the "Matrix protocol", which is a different protocol and has nothing to do with XMPP except for having a common goal) is one example of such a library. According to their web site, there is support for Jingle, but I couldn't find any documentation about it.
However, as I mentioned above, Jingle is only about how to negotiate data streams, not the data streams and VoIP itself.
So what that library probably helps you with is parsing of the Jingle XMPP messages that are needed to set up a RTP data stream.
For displaying and transfering the RTP stream, however, you need additional libraries. For that, have a look at the following SO questions and answers:
Open Source .net C# library for Real Time transport Protocol
Streaming Avi files from C# using RTP
I hope I could give you some useful hints...

ios 7 fetch offline message from xmpp server

I am developing chat application using XMPP protocol.
My development target is iOS 7.0
Every think is working fine user can able to communicate only when they are online.
But I want to notify user message has come when they are offline.
I have tried iphone XMPP App run background
But it doesn’t work for me.
First think it is possible or not?
Using what VIOP, background fetch or some other way?
If yes please let me know. how?.
The thread you are referring mention declaring that your app is a VoIP app to be allowed to constantly run in background.
It is technically possible but has two drawbacks:
If your application does not do voip, Apple will reject it (as misleading).
Battery consumption will be excessive as you will stay connected.
The state of the art is to fallback to Apple push notification service when the TCP connection between the client and the server is not established. This is battery efficient and provide a very good way to notify the user of new messages.

Load testing: Choosing between a tool or simulating clients on my own for this scenario?

I want to load test my application and I'm deciding b/w choosing a load testing service or simulating the clients on my own.
My question is whether I can accomplish this user scenario using any of the load testing tools available.
My test will have two types of users, A & B. Communication would be between A and B. A-A communication and B-B communication is not there.
I want Users to login to my application through mobile or web. Either type of users could log in through either type of platform.
Make multiple GET/PUT/POST requests to my application server with specific parameters.
Be able to exchange video or text messages by integrating through services like Pusher and Vidyo.
'3' is probably the most important requirement for me, and I'm wondering if I could simulate the dummy users so that it listens to a pusher channel and can open up a Vidyo iframe in the emulated browser / mobile device for a specific pusher message?
I got on call with Blazemeter and turns out they or anyone in the market doesn't support plugins on emulated browsers. I finally simulated the clients on my own replicating all the server calls a typical browser or mobile device makes for my application.
I haven't yet been able to load test Vidyo and don't know if there's a way to do it except by opening up conferences manually.
I was able to load test services like Pusher and SQS successfully.

UDP Hole punching unsuccessful, but tests show it should work (mobile network)

For the past two week I have been unsuccessfully trying to implement udp hole punching, but I'm not sure why. I understand that the algorithm for hole punching is not guaranteed to work, but I believe it should work in my test case because I have noticed that once I bind my socket on my home-network, the port is the same to the outside world as it is locally, and stays that way for all connections made from this socket. Any help after reviewing my trials would be appreciated.
I have three computers, my osx desktop, my iPhone, and my amazon ec2 ami.
on the desktop I've built a cocoa app which uses the GCDAsyncUDPSocket library to bind a port and contact the ec2 server, where a java app using apache's mina library stores the sockets external ip/port and associates it with a username passed in the payload.
the iphone, which is on the AT&T network runs an app which uses the same GCDAsyncUDPSocket library to contact the ec2 server with the same username, which then the ec2 does a lookup for the username, finds the desktops info and informs the desktop of the iphones address and the iphone of the desktops address.
now the iphone & the desktop know about each other they start shooting off packets at each other in hopes to get a punched hole.
in theory this should work, but maybe I am missing something about mobile networks that would make this difficult? But then again running a simple udp echoer on a 4th external computer to manually msg the desktop did not work either, so maybe its my router, but I don't see how that could be as all my tests show that the port the desktop asks for is the same one assigned by the router.
I've been at this for nearly two weeks with little progress and any tips would be appreciated!
"once I bind my socket on my home-network, the port is the same to the outside world as it is locally"
I highly doubt that. To traverse NAT given peers A and B which have sent datagrams to a 3rd party: S you need to send datagrams from A to B and vice versa using their public IPs as seen by S and their port as seen by S (i.e. not the port A, B are bound to from their point of view).