Secure URL Schema communication - iphone

I want to have communication between two apps using url schema.
I want to know what should I take care so that any other third party app does not try to represent my either of the app.
Eg. A communicates with B and vice-versa.
if C tries to communicate with B representing as to be A OR
if C tries to communicate with A representing as to be B

Related

Multipeer connection Webrtc Flutter

I am trying to make 3 peer video chat using Webrtc in Flutter. A needs to see B and C. B needs to see A and C. C needs to A and B. I also use socket.io for signalling server. I used 2 peerconnection. two peer connection is successful. When I tried to connect the third one and tried to pass offer I got an error.
to execute 'createAnswer' on 'RTCPeerConnection': PeerConnection cannot create an answer in a state other than have-remote-offer or have-local-pranswer.
is my approach is bad for multiple peer connection?
A mesh of 3 users means each user sets up two connections, one to each of the other two users. At each client's end, these are two entirely different RTCPeerConnections, and you can't reuse candidates between them, as each candidate contains port numbers allocated specifically for the media and the target it is to be sent to.
If you know how to set up one connection, you know how to set up two. Just keep things separate.
just set 1 connection and try to use the direction: many to many

Handling websocket connections connected to different replicas

Backend is running on kubernetes which has N replicas.
Frontend users(browsers) listen websocket for real-time messages.
Since Backend has N replicas, each browser connects to different one.
Let's say there are users A B C, all have opened 2 tabs, A1 A2 B1 B2 C1 C2.
Backend-replica-1 may hold websocket connections of A1 B1
Backend-replica-2 may hold websocket connections of A2 B2 C1 C2
(please correct me if I'm wrong till here. But, as far as I know and have tested, this is how it works)
To broadcast a message to ALL users, I publish a notification to RabbiqMQ with the message I wanted. I am using Fanout exchange, so that Each backend replica will consume that notification. Then each server sends the message to all users(connections) that it has.
One question, is if this is the correct way of doing it or is there any better way? Would it be more sensible to have a separate server for only handling WS connections?
Now, I need a solution to detect if a user closed all tabs(left the application), and update that user in db. My initial idea was to detect that on websocket disconnect event, check if user has any active connections left. But doing that seems very complex, because user may have opened 3 tabs, each connecting to different backend server.
Anyone has a clue on how to achieve it?
To keep track of who is connected and who closed all tabs, you need to have one DB-like instance. All you need to do is to publish an event to that instance when someone connects or disconnects.
A simple implementation would to have a dictionary with a user identifier as key and number of session as a value.
When a user connects to a websocket, you publish a connected event that increments the number of sessions.
When a user disconnects, you publish a disconnected event that decrements the number of sessions and return the remaining number of session or just a boolean if the number is equal to 0. Then you can do whatever you need to do to clean up his session.
Note: you need to make the write operation synchronous if you will have multiple threads receiving the events. A good solution is to use a SQL database which support ACID out of the box.
If you need to more control, you can extend the solution to have a publish subscribe architecture. Where the connection is bidirectional rather than the unidirectional method above. This way, if someone connects in another tab, you can interact with the first tab and show a message or disconnect based on your needs.

P2P web based automated response based on user query

I would like to create a web based p2p application between two nodes. A website shows a list of nodes. When a user (say A) clicks on a node, it must setup a p2p chat like connection between the two. It goes like this : once connection is established, node A can send a query message to B. Once B receives the query message, B must respond with the correct answer, (if A queries : RETRIEVE x.txt, B's response must be the contents of x.txt) I would like to be pointed into the right direction regarding the proper tech / protocols to be used. Thank you😀
Firstly, if you want to reach all the nodes, you need to collect their information so that when you click, you can connect to it.
Secondly, if you want to connect to these nodes, you need to do NAT traversal so that they can connect to each other.
Thirdly, you may want a reliable connection, so you need reliable UDP.
According these, you need the following protocols:
Creating a center controller like tracker to collect infomations
Creating NAT traversal, like nat-pmp and upnp, and it's better if you can build a ICE in the center controller
When click to some node, using udp to connect to it
If you want the connection reliable, you may also need to do reliable UDP, like QUIC, kcp or libutp.

Multiple endpoints or a single endpoint with additional logic in a handler?

I am developing an app that will be integrated into different platforms (e.g p1, p2, ...). Let's say users will be able to subscribe so a payload will be sent to the endpoint /subscribe.
However the payload being sent will not be the same across platforms p1 or p2 (payload cannot be modified). Therefore I am wondering should I have two different endpoints /p1/subscribe and /p2/subscribe or should I have a single endpoint with additional code in the handler that will check the payload and based on it call the right (sub)handler.
It makes more sense to have a single endpoint in my opinion but would like to hear yours.
You could have a single 'gateway' endpoint which delegates to /p1/subscribe or /p2/subscribe based on e.g. HTTP headers.
The exact architecture depends on whether you merely want to direct P1 and P2 to the appropriate services or actively want to prevent P1 from accessing P2's services.

What technologies should I use to create a real time One to One chat?

I'm a PHP developer with a lack of experience on other sever side langages.
I’d like you to give me leads, advice, keywords or whatever that could help me refine my research better.
What I want to do is basically to create a one to one mobile app chat that will scale.
There will be channels of 3 users: User A, User B and the "computer" pushing some messages according to some channels informations like the last time a message has been sent, etc.
User A should know if User B is online, writing, etc.
Every conversation should be stored in a database and would be analyzed by some algorithms. Those algorithms would also analyzed stuffs on user Facebook open graph.
The application should be able to send notification on IOS and Android.
A web administration should allow admin to set some stuff that will define what kind of message would be sent by the "computer".
I'v read lot of posts about websocket, xmpp, node.js, socket.io, etc but I don't have enough knowledge in those areas to decide what architecture should I build to make everything works together. Or maybe there is some cloud base solutions that would fit my needs...
Thanks
As you've stated there are many ways to implement that kind of structure but I am going to write about node.js + socket.io part;
1) It is scalable. You can use cluster, nginx, haproxy. etc. to apply load balancing to your socket.io application (see here) Of course you've to use redis or mongo or some kind of store for socket.io that different servers and processes can communicate each other. (see here)
2) socket.io have rooms. That means clients and any computer bots can join that room to share events with each other. So, in your scenario User A, User B and a computer bot should join to same room and events sent to that room will be broadcasted to every room member. (events can vary as online, typing, new message, anything) (see here)
3) node.js can send push notifications both for iOS and Android.
4) You can write every message to database of your choice on new message event.
5) You can create a REST api with Express framework for your Administration page. And you can use passport for authentication and authorization purposes. You can consume the rest api with Jquery or some other frontend framework like React etc.
Meteor is very well suited for something like this and gives you everything you need. There are also open sourced chat systems built with meteor already to get an idea of where you need to go. The more custom route would be to do what #cdagli said.