/// <summary> /// Loads from json. /// </summary> /// <param name="jsonProperty">The json property.</param> /// <param name="service"></param> internal override void LoadFromJson(JsonObject jsonProperty, ExchangeService service) { foreach (string key in jsonProperty.Keys) { switch (key) { case XmlElementNames.PhoneCallState: this.state = jsonProperty.ReadEnumValue <PhoneCallState>(key); break; case XmlElementNames.ConnectionFailureCause: this.connectionFailureCause = jsonProperty.ReadEnumValue <ConnectionFailureCause>(key); break; case XmlElementNames.SIPResponseText: this.sipResponseText = jsonProperty.ReadAsString(key); break; case XmlElementNames.SIPResponseCode: this.sipResponseCode = jsonProperty.ReadAsInt(key); break; default: break; } } }
/// <summary> /// Refreshes the state of this phone call. /// </summary> public void Refresh() { PhoneCall phoneCall = service.UnifiedMessaging.GetPhoneCallInformation(this.id); this.state = phoneCall.State; this.connectionFailureCause = phoneCall.ConnectionFailureCause; this.sipResponseText = phoneCall.SIPResponseText; this.sipResponseCode = phoneCall.SIPResponseCode; }
/// <summary> /// Refreshes the state of this phone call. /// </summary> public async System.Threading.Tasks.Task Refresh() { PhoneCall phoneCall = await service.UnifiedMessaging.GetPhoneCallInformation(this.id).ConfigureAwait(false); this.state = phoneCall.State; this.connectionFailureCause = phoneCall.ConnectionFailureCause; this.sipResponseText = phoneCall.SIPResponseText; this.sipResponseCode = phoneCall.SIPResponseCode; }
/// <summary> /// Refreshes the state of this phone call. /// </summary> void Refresh() { PhoneCall phoneCall = service.UnifiedMessaging.GetPhoneCallInformation(this.id); this.state = phoneCall.State; this.connectionFailureCause = phoneCall.ConnectionFailureCause; this.sipResponseText = phoneCall.SIPResponseText; this.sipResponseCode = phoneCall.SIPResponseCode; }
/// <summary> /// PhoneCall Constructor. /// </summary> /// <param name="service">EWS service to which this object belongs.</param> internal PhoneCall(ExchangeService service) { EwsUtilities.Assert( service != null, "PhoneCall.ctor", "service is null"); this.service = service; this.state = PhoneCallState.Connecting; this.connectionFailureCause = ConnectionFailureCause.None; this.sipResponseText = PhoneCall.SuccessfulResponseText; this.sipResponseCode = PhoneCall.SuccessfulResponseCode; }
/// <summary> /// Tries to read an element from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>True if element was read.</returns> internal override bool TryReadElementFromXml(EwsServiceXmlReader reader) { switch (reader.LocalName) { case XmlElementNames.PhoneCallState: this.state = reader.ReadElementValue <PhoneCallState>(); return(true); case XmlElementNames.ConnectionFailureCause: this.connectionFailureCause = reader.ReadElementValue <ConnectionFailureCause>(); return(true); case XmlElementNames.SIPResponseText: this.sipResponseText = reader.ReadElementValue(); return(true); case XmlElementNames.SIPResponseCode: this.sipResponseCode = reader.ReadElementValue <int>(); return(true); default: return(false); } }
/// <summary> /// Tries to read an element from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>True if element was read.</returns> internal override bool TryReadElementFromXml(EwsServiceXmlReader reader) { switch (reader.LocalName) { case XmlElementNames.PhoneCallState: this.state = reader.ReadElementValue<PhoneCallState>(); return true; case XmlElementNames.ConnectionFailureCause: this.connectionFailureCause = reader.ReadElementValue<ConnectionFailureCause>(); return true; case XmlElementNames.SIPResponseText: this.sipResponseText = reader.ReadElementValue(); return true; case XmlElementNames.SIPResponseCode: this.sipResponseCode = reader.ReadElementValue<int>(); return true; default: return false; } }
/// <summary>Connect to a server.</summary> /// <param name="serverName">IP address or hostname of the server.</param> /// <param name="serverPort">IP port on which the server is listening.</param> /// <remarks>The first client to connect becomes the hosting player.</remarks> public void Connect(string serverName, int serverPort) { Debug.Assert(status == NetworkStatus.Disconnected); serverIsOnSameComputer = (serverName == "localhost"); outboundVideoFrameHistory = new OutboundVideoFrameHistory(); inboundVideoFrameHistories = new Dictionary <int, InboundVideoFrameHistory>(); soundBuffers = new Dictionary <int, Buffer3D>(); client = new Microsoft.DirectX.DirectPlay.Client(InitializeFlags.DisableParameterValidation); client.ConnectComplete += new ConnectCompleteEventHandler(onConnectComplete); client.Receive += new ReceiveEventHandler(onReceive); client.SessionTerminated += new SessionTerminatedEventHandler(onSessionTerminated); status = NetworkStatus.Connecting; // trigger NAT traversal EnabledAddresses enabledAddresses = NatResolver.TestNatTraversal(serverName, serverPort); ApplicationDescription description = new ApplicationDescription(); description.GuidApplication = new Guid("{920BAF09-A06C-47d8-BCE0-21B30D0C3586}"); // try first using the host's public address using (Address hostAddress = (enabledAddresses == null ? new Address(serverName, serverPort) : new Address(enabledAddresses.HostPublicAddress, enabledAddresses.HostPublicPort))) { hostAddress.ServiceProvider = Address.ServiceProviderTcpIp; using (Address device = new Address()) { device.ServiceProvider = Address.ServiceProviderTcpIp; device.AddComponent(Address.KeyTraversalMode, Address.TraversalModeNone); if (enabledAddresses != null) { device.AddComponent(Address.KeyPort, enabledAddresses.ClientPrivatePort); } using (NetworkPacket packet = new NetworkPacket()) { try { client.Connect(description, hostAddress, device, packet, 0); } catch (Exception e) { status = NetworkStatus.Disconnected; ConnectionFailureCause cause = (e is NoConnectionException ? ConnectionFailureCause.NoConnection : (e is NotHostException ? ConnectionFailureCause.NotHost : (e is SessionFullException ? ConnectionFailureCause.SessionFull : ConnectionFailureCause.Other))); // try again using the host's private address if (enabledAddresses != null) { using (Address hostPrivateAddress = new Address(enabledAddresses.HostPrivateAddress, enabledAddresses.HostPrivatePort)) { try { client.Connect(description, hostAddress, device, packet, 0); } catch { NetworkMessage message = new NetworkMessage(0, (byte)ReservedMessageType.ConnectionFailed, new byte[1] { (byte)cause }); lock (networkMessages) { networkMessages.Enqueue(message); } return; } } } else { NetworkMessage message = new NetworkMessage(0, (byte)ReservedMessageType.ConnectionFailed, new byte[1] { (byte)cause }); lock (networkMessages) { networkMessages.Enqueue(message); } return; } } } } } // launch a timer to monitor timeout timeoutTimer = new System.Threading.Timer(onTimeout, client, 4000, 0); }