IEnumerator DiablePresenceAsync(UnityTask <string> task)
        {
            var btask = BalancerClient.GetServerUrl(Url, IsCluster, ApplicationKey);

            yield return(TaskManager.StartRoutine(btask.WaitRoutine()));

            if (btask.IsFaulted)
            {
                task.Exception = btask.Exception;
                task.Status    = TaskStatus.Faulted;
                yield break;
            }

            var server      = btask.Result;
            var presenceUrl = String.IsNullOrEmpty(server) ? server : server[server.Length - 1] == '/' ? server : server + "/";

            presenceUrl = String.Format("{0}presence/disable/{1}/{2}", presenceUrl, ApplicationKey, Channel);
            var content = String.Format("privatekey={0}", PrivateKey);

            var htask = HttpClient.PostAsync(presenceUrl, content);

            yield return(TaskManager.StartRoutine(htask.WaitRoutine()));

            if (htask.IsFaulted)
            {
                task.Exception = htask.Exception;
                task.Status    = TaskStatus.Faulted;
                yield break;
            }

            task.Result = htask.Content;
        }
        IEnumerator GetPresenceAsync(UnityTask <Presence> task)
        {
            var btask = BalancerClient.GetServerUrl(Url, IsCluster, ApplicationKey);

            yield return(TaskManager.StartRoutine(btask.WaitRoutine()));

            if (btask.IsFaulted)
            {
                task.Exception = btask.Exception;
                task.Status    = TaskStatus.Faulted;
                yield break;
            }

            var server = btask.Result;

            var presenceUrl = String.IsNullOrEmpty(server) ? server : server[server.Length - 1] == '/' ? server : server + "/";

            presenceUrl = String.Format("{0}presence/{1}/{2}/{3}", presenceUrl, ApplicationKey, AuthenticationToken, Channel);

            var htask = HttpClient.GetAsync(presenceUrl);

            yield return(TaskManager.StartRoutine(htask.WaitRoutine()));

            if (htask.IsFaulted)
            {
                task.Exception = htask.Exception;
                task.Status    = TaskStatus.Faulted;
                yield break;
            }

            task.Result = Deserialize(htask.Content);
        }
 /// <summary>
 /// Retrieves an Ortc Server url from the Ortc Balancer
 /// </summary>
 /// <param name="balancerUrl">The Ortc Balancer url.</param>
 /// <param name="applicationKey"></param>
 /// <remarks></remarks>
 public static UnityTask<string> GetServerFromBalancer(string balancerUrl, string applicationKey)
 {
     var client = new BalancerClient
     {
         Url = balancerUrl,
         ApplicationKey = applicationKey,
     };
     return client.GetServerFromBalancer();
 }
 /// <summary>
 /// Retrieves an Ortc Server url from the Ortc Balancer
 /// </summary>
 /// <param name="url"></param>
 /// <param name="isCluster"></param>
 /// <param name="applicationKey"></param>
 /// <returns></returns>
 public static UnityTask<string> GetServerUrl(string url, bool isCluster, string applicationKey)
 {
     var client = new BalancerClient
     {
         Url = url,
         IsCluster = isCluster,
         ApplicationKey = applicationKey,
     };
     return client.GetServerUrl();
 }
Exemple #5
0
        /// <summary>
        /// Retrieves an Ortc Server url from the Ortc Balancer
        /// </summary>
        /// <param name="balancerUrl">The Ortc Balancer url.</param>
        /// <param name="applicationKey"></param>
        /// <remarks></remarks>
        public static UnityTask <string> GetServerFromBalancer(string balancerUrl, string applicationKey)
        {
            var client = new BalancerClient
            {
                Url            = balancerUrl,
                ApplicationKey = applicationKey,
            };

            return(client.GetServerFromBalancer());
        }
Exemple #6
0
        /// <summary>
        /// Retrieves an Ortc Server url from the Ortc Balancer
        /// </summary>
        /// <param name="url"></param>
        /// <param name="isCluster"></param>
        /// <param name="applicationKey"></param>
        /// <returns></returns>
        public static UnityTask <string> GetServerUrl(string url, bool isCluster, string applicationKey)
        {
            var client = new BalancerClient
            {
                Url            = url,
                IsCluster      = isCluster,
                ApplicationKey = applicationKey,
            };

            return(client.GetServerUrl());
        }