Windows8.Conference.WebRTC.Signalling.Attach C# (CSharp) Method

Attach() public method

public Attach ( FM conference, string sessionId, Action callback ) : void
conference FM
sessionId string
callback Action
return void
        public void Attach(FM.IceLink.Conference conference, string sessionId, Action<string> callback)
        {
            Conference = conference;
            SessionId = sessionId;

            if (UseWebSyncExtension)
            {
                // Manage the conference automatically using a WebSync
                // channel. P2P links will be created automatically to
                // peers that join the same channel.
                WebSyncClient.JoinConference(new JoinConferenceArgs("/" + SessionId, conference)
                {
                    OnFailure = (e) =>
                    {
                        callback(string.Format("Could not attach signalling to conference {0}. {1}", SessionId, e.Exception.Message));
                    },
                    OnSuccess = (e) =>
                    {
                        callback(null);
                    }
                });
            }
            else
            {
                // When the conference generates an offer/answer or candidate,
                // we want to send it to the remote peer immediately.
                Conference.OnLinkOfferAnswer += SendOfferAnswer;
                Conference.OnLinkCandidate += SendCandidate;

                // When we receive an offer/answer or candidate, we want to
                // inform the conference immediately.
                WebSyncClient.OnNotify += ReceiveOfferAnswerOrCandidate;

                // Subscribe to a WebSync channel. When another client joins the same
                // channel, create a P2P link. When a client leaves, destroy it.
                WebSyncClient.Subscribe(new SubscribeArgs("/" + SessionId)
                {
                    OnFailure = (e) =>
                    {
                        callback(string.Format("Could not attach signalling to conference {0}. {1}", SessionId, e.Exception.Message));
                    },
                    OnReceive = (e) => { },
                    OnSuccess = (e) =>
                    {
                        callback(null);
                    }
                }
                .SetOnClientSubscribe((e) =>
                {
                    // Kick off a P2P link.
                    var peerId = e.SubscribedClient.ClientId.ToString();
                    var peerState = e.SubscribedClient.BoundRecords;
                    Conference.Link(peerId, peerState);
                })
                .SetOnClientUnsubscribe((e) =>
                {
                    // Tear down a P2P link.
                    var peerId = e.UnsubscribedClient.ClientId.ToString();
                    Conference.Unlink(peerId);
                }));
            }
        }

Usage Example

Ejemplo n.º 1
0
        public void StartConference(Action <string> callback)
        {
            // Create a WebRTC audio stream description (requires a
            // reference to the local audio feed).
            AudioStream = new AudioStream(LocalMedia.LocalMediaStream);

            // Create a WebRTC video stream description (requires a
            // reference to the local video feed). Whenever a P2P link
            // initializes using this description, position and display
            // the remote video control on-screen by passing it to the
            // layout manager created above. Whenever a P2P link goes
            // down, remove it.
            VideoStream             = new VideoStream(LocalMedia.LocalMediaStream);
            VideoStream.OnLinkInit += AddRemoteVideoControl;
            VideoStream.OnLinkDown += RemoveRemoteVideoControl;

            // Create a new IceLink conference.
            Conference = new FM.IceLink.Conference(IceLinkServerAddress, new Stream[] { AudioStream, VideoStream });

            // Supply TURN relay credentials in case we are behind a
            // highly restrictive firewall. These credentials will be
            // verified by the TURN server.
            Conference.RelayUsername = "******";
            Conference.RelayPassword = "******";

            // Add a few event handlers to the conference so we can see
            // when a new P2P link is created or changes state.
            Conference.OnLinkInit += LogLinkInit;
            Conference.OnLinkUp   += LogLinkUp;
            Conference.OnLinkDown += LogLinkDown;

            // Attach signalling to the conference.
            Signalling.Attach(Conference, SessionId, callback);
        }
All Usage Examples Of Windows8.Conference.WebRTC.Signalling::Attach