Exemple #1
0
 private static string   UrlEncode(string str)
 {
     if (str == null)
     {
         return(null);
     }
     return(PublisherAPI.UrlEncode(str, Encoding.UTF8));
 }
Exemple #2
0
        public void             Connect(string username, string password, Action <HttpWebResponse, string> onCompleted)
        {
            string         endpoint = "https://kharma.unity3d.com/login";
            HttpWebRequest request  = this.CreateRequest(endpoint);
            StringBuilder  buffer   = Utility.GetBuffer();

            buffer.Append("user="******"&pass="******"&unityversion=");
            buffer.Append(PublisherAPI.UrlEncode(Application.unityVersion));
            buffer.Append("&toolversion=");
            buffer.Append(PublisherAPI.UrlEncode("V4.1.0"));
            buffer.Append("&license_hash=");
            buffer.Append(PublisherAPI.UrlEncode(this.GetLicenseHash()));
            buffer.Append("&hardware_hash=");
            buffer.Append(PublisherAPI.UrlEncode(this.GetHardwareHash()));

            byte[] content = Encoding.UTF8.GetBytes(Utility.ReturnBuffer(buffer));

            request.Headers         = new WebHeaderCollection();
            request.Method          = "POST";
            request.ContentType     = "application/x-www-form-urlencoded";
            request.ContentLength   = content.Length;
            request.Accept          = "application/json";
            request.KeepAlive       = true;
            request.Host            = "kharma.unity3d.com";
            request.CookieContainer = new CookieContainer();

            using (Stream stream = request.GetRequestStream())
            {
                stream.Write(content, 0, content.Length);
            }

            this.HandleRequest(request, endpoint.GetHashCode(), (r, s) =>
            {
                if (r == null)
                {
                }
                else
                {
                    if (Conf.DebugMode == Conf.DebugState.Verbose)
                    {
                        Debug.Log(s);
                    }
                    this.session = JsonUtility.FromJson <Session>(s);
                }

                onCompleted(r, s);
            });
        }