using System; using System.Collections.Generic; using UnityEngine.Scripting; using System.Runtime.Serialization; using Newtonsoft.Json; using Newtonsoft.Json.Converters; namespace Unity.Services.Relay.Models { /// /// Endpoint connection details for a relay server /// /// Canonical connection type /// IP network (udp, tcp) /// Is the delivery of data guaranteed /// Is the endpoint secured /// Host name or address of the relay server /// Port number [Preserve] [DataContract(Name = "RelayServerEndpoint")] public class RelayServerEndpoint { [Preserve] public RelayServerEndpoint(string connectionType, NetworkOptions network, bool reliable, bool secure, string host, int port) { ConnectionType = connectionType; Network = network; Reliable = reliable; Secure = secure; Host = host; Port = port; } [Preserve] [DataMember(Name = "connection_type", IsRequired = true, EmitDefaultValue = true)] public string ConnectionType{ get; } [Preserve] [JsonConverter(typeof(StringEnumConverter))] [DataMember(Name = "network", IsRequired = true, EmitDefaultValue = true)] public NetworkOptions Network{ get; } [Preserve] [DataMember(Name = "reliable", IsRequired = true, EmitDefaultValue = true)] public bool Reliable{ get; } [Preserve] [DataMember(Name = "secure", IsRequired = true, EmitDefaultValue = true)] public bool Secure{ get; } [Preserve] [DataMember(Name = "host", IsRequired = true, EmitDefaultValue = true)] public string Host{ get; } [Preserve] [DataMember(Name = "port", IsRequired = true, EmitDefaultValue = true)] public int Port{ get; } /// /// IP network (udp, tcp) /// /// IP network (udp, tcp) [JsonConverter(typeof(StringEnumConverter))] public enum NetworkOptions { /// /// Enum Udp for value: udp /// [EnumMember(Value = "udp")] Udp = 1, /// /// Enum Tcp for value: tcp /// [EnumMember(Value = "tcp")] Tcp = 2 } } }