예제 #1
0
        void ProcessSignalingMessage(ARDSignalingMessage message)
        {
            switch (message.Type)
            {
            case ARDSignalingMessageType.Offer:
            case ARDSignalingMessageType.Answer:
                ARDSessionDescriptionMessage sdpMessage = message as ARDSessionDescriptionMessage;
                _peerConnection.SetRemoteDescriptionWithDelegate(this, sdpMessage.Description);
                break;

            case ARDSignalingMessageType.Candidate:
                ARDICECandidateMessage candidateMessage = message as ARDICECandidateMessage;
                _peerConnection.AddICECandidate(candidateMessage.Candidate);
                break;

            case ARDSignalingMessageType.Bye:
                // Other client disconnected.
                // TODO(tkchin): support waiting in room for next client. For now just
                Disconnect();
                break;

            default:
                break;
            }
        }
예제 #2
0
        public static ARDSignalingMessage MessageFromJSONString(string json)
        {
            var values = JsonConvert.DeserializeObject <Dictionary <string, string> >(json);
            ARDSignalingMessage message = new ARDSignalingMessage();
            var type = values["type"];

            if (type == "candidate")
            {
                RTCICECandidate candidate = new RTCICECandidate(values["id"], nint.Parse(values["label"]), values["candidate"]);
                message = new ARDICECandidateMessage(candidate);
            }
            else if (type == "offer" || type == "answer")
            {
                RTCSessionDescription description = new RTCSessionDescription(type, values["sdp"]);
                message = new ARDSessionDescriptionMessage(description);
            }
            else if (type == "bye")
            {
                message = new ARDByeMessage();
            }
            else
            {
                System.Diagnostics.Debug.WriteLine($"Unexpected type: {type}");
            }
            return(message);
        }
예제 #3
0
        public void PeerConnection(RTCPeerConnection peerConnection, RTCICECandidate candidate)
        {
            ARDICECandidateMessage message = new ARDICECandidateMessage(candidate);

            SendSignalingMessage(message).Wait();
        }