/// <summary>
        /// Extracting event from the json.
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public CallingServerEventBase ExtractEvent(string content)
        {
            CloudEvent cloudEvent = CloudEvent.Parse(BinaryData.FromString(content));

            if (cloudEvent != null && cloudEvent.Data != null)
            {
                if (cloudEvent.Type.Equals(CallingServerEventType.CallConnectionStateChangedEvent.ToString()))
                {
                    return(CallConnectionStateChangedEvent.Deserialize(cloudEvent.Data.ToString()));
                }
                else if (cloudEvent.Type.Equals(CallingServerEventType.ToneReceivedEvent.ToString()))
                {
                    return(ToneReceivedEvent.Deserialize(cloudEvent.Data.ToString()));
                }
                else if (cloudEvent.Type.Equals(CallingServerEventType.PlayAudioResultEvent.ToString()))
                {
                    return(PlayAudioResultEvent.Deserialize(cloudEvent.Data.ToString()));
                }
                else if (cloudEvent.Type.Equals(CallingServerEventType.AddParticipantResultEvent.ToString()))
                {
                    return(AddParticipantResultEvent.Deserialize(cloudEvent.Data.ToString()));
                }
            }

            return(null);
        }
Example #2
0
        public void CallConnectionStateChangedEventTest()
        {
            var json = "{\"serverCallId\":\"serverCallId\",\"callConnectionId\":\"callConnectionId\",\"callConnectionState\":\"connected\"}";

            var c = CallConnectionStateChangedEvent.Deserialize(json);

            Assert.AreEqual("serverCallId", c.ServerCallId);
            Assert.AreEqual("callConnectionId", c.CallConnectionId);
            Assert.AreEqual(CallConnectionState.Connected, c.CallConnectionState);
        }
        /// <summary>
        /// Extracting event from the json.
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>
        public CallingServerEventBase ExtractEvent(string content)
        {
            CloudEvent cloudEvent = CloudEvent.Parse(BinaryData.FromString(content));

            if (cloudEvent != null && cloudEvent.Data != null)
            {
                if (cloudEvent.Type.Equals(CallingServerEventType.CallConnectionStateChangedEvent.ToString()))
                {
                    return(CallConnectionStateChangedEvent.Deserialize(cloudEvent.Data.ToString()));
                }
            }

            return(null);
        }