HomeGuidesAPI Reference
HubBlogChangelogSupport ForumLog In
Guides

Streaming

Here's how to stream an interactive Windows desktop from one Peer to another.

🚧

Platform limitations on streaming

In its current beta state, the Rainway SDK only supports streams

  • from a Windows desktop, using the Native Runtime,
  • to a web browser, using the Web Runtime.

So make sure you have both of these set up if you want to try out streaming.

If you want to try streaming without writing any code yourself, you can install the C# demo on a Windows desktop, and use the web demo page to connect to it from a browser on another computer.

Before a stream is initiated, the peer-to-peer connection is symmetrical. Once streaming begins, this changes. The streaming Peer (native app) is referred to as the host, and the Peer consuming the stream (the host's web app) is the client.

A desktop stream may be initiated when a client requests it. Here's what that looks like.

Requested streams

Stream requests come in on the Peer as an event, named "stream-request". The host specifies the configuration for the stream, optionally considering what the peer requested.

peer.addEventListener("stream-request", async (ev) => {
  // who's requesting the stream
  const requesterId = ev.id;
  
  // what input level are they requesting
  const requesterPerms = ev.permissions;
  
  // we can choose to accept or reject, here we'll accept
  // the returned promise resolves to an OutboundStream object
  const stream = await ev.accept({
    // grant them what they asked for
    permissions: requesterPerms,
    
    // share the full desktop
    type: RainwayStreamType.FullDesktop
	});
});

Calling accept will start streaming media to the web app, which it can display in a container on the page. It returns a Promise that resolves to an OutboundStream that can be used to further control the stream session.

Alternatively, the host can call reject with a human-readable reason string.