public void OnCreateSuccess(SessionDescription origSdp) { outerInstance.RunOnUiThread(() => { outerInstance.logAndToast("Sending " + origSdp.Type); SessionDescription sdp = new SessionDescription(origSdp.Type, outerInstance.preferISAC(origSdp.Description)); JSONObject json = new JSONObject(); jsonPut(json, "type", sdp.Type.CanonicalForm()); jsonPut(json, "sdp", sdp.Description); outerInstance.sendMessage(json); outerInstance.pc.SetLocalDescription(outerInstance.sdpObserver, sdp); }); }
public void onMessage(string data) { try { JSONObject json = new JSONObject(data); string type = (string)json.Get("type"); if (type.Equals("candidate")) { IceCandidate candidate = new IceCandidate((string)json.Get("id"), json.GetInt("label"), (string)json.Get("candidate")); if (outerInstance.queuedRemoteCandidates != null) { outerInstance.queuedRemoteCandidates.AddLast(candidate); } else { outerInstance.pc.AddIceCandidate(candidate); } } else if (type.Equals("answer") || type.Equals("offer")) { SessionDescription sdp = new SessionDescription(SessionDescription.SessionDescriptionType.FromCanonicalForm(type), outerInstance.preferISAC((string)json.Get("sdp"))); outerInstance.pc.SetRemoteDescription(outerInstance.sdpObserver, sdp); } else if (type.Equals("bye")) { outerInstance.logAndToast("Remote end hung up; dropping PeerConnection"); outerInstance.disconnectAndExit(); } else { throw new Exception("Unexpected message: " + data); } } catch (JSONException e) { throw new Exception("Error", e); } }
public static RTCSessionDescriptionInit FromNative(this Webrtc.SessionDescription nativeDescription) => new RTCSessionDescriptionInit { //// TODO: No way to get Type, it is class!!!! Type = nativeDescription.Type.FromNative(), Sdp = nativeDescription.Description };
/// <summary> /// Handles the message sent by the other peer or the server /// </summary> /// <param name="message">Message.</param> private void HandleMessage (string message) { ServerMessage serverMessage = JsonConvert.DeserializeObject<ServerMessage> (message); switch (serverMessage.Type) { //this message comes whent the connection to the sever is opened case "OPEN": PeerConnectedEventArgs peerConnectedEventArgs = new PeerConnectedEventArgs (); peerConnectedEventArgs.PeerId = this.Id; OnPeerConnected (peerConnectedEventArgs); break; //this message comes in when the offer is answered by the other peer. Contains the remote session desciption case "ANSWER": Negotiator negotiator = Negotiator.GetNegotiator (); SessionDescription sessionDescription = new SessionDescription (SessionDescription.Type.Answer, serverMessage.Payload.Sdp.Sdp); negotiator.HandleMessage (serverMessage, sessionDescription); break; } }
public void OnCreateSuccess(SessionDescription p0) { _observer?.OnCreateSuccess(p0.ToNet()); }