Ask Your Question
2

What is the issue with Javascript Socket.io and simple-peer, and how can data be sent only from client 2 to client 1 without sending streams to each other?

asked 2023-07-15 15:02:39 +0000

ladyg gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-07-15 15:26:01 +0000

nofretete gravatar image

The issue with using Socket.io and simple-peer to send data between clients is that by default, both clients will send streams to each other. This means that both clients will have access to each other's data, which may not be appropriate for certain applications.

To send data only from client 2 to client 1, you can use a signaling server to establish a connection between the two clients, but instead of creating a peer-to-peer connection, you can create a one-way data channel using WebRTC data channels. This allows client 2 to send data to client 1 without sending streams to each other.

To implement this, you can use the WebRTC API to create a data channel between the two clients, and then use the signaling server to establish the connection and exchange messages between the two clients. When client 2 wants to send data to client 1, it can send a message over the data channel, and client 1 can receive the message and process it accordingly.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-15 15:02:39 +0000

Seen: 8 times

Last updated: Jul 15 '23