Example #1
0
    void Awake()
    {
        //make sure we only have one object with this Gamedonia script at any time
        if (_instance != null)
        {
            Destroy(gameObject);
            return;
        }

        _instance     = this;
        notifications = new List <Dictionary <string, object> >();
        DontDestroyOnLoad(this);

                #if UNITY_EDITOR
                #elif UNITY_IOS
        if ((notificationType & RemoteNotificationType.Badge) != 0 && clearBadgeOnActivate)
        {
            ClearBadge();
        }
                #endif


        GDService service = new GDService();
        service.ProfileEvent += new ProfilerEventHandler(Profile);
        GamedoniaDevices.services.Add(service);

        GamedoniaDevices.GetProfile(OnGetProfile);
    }
Example #2
0
 public ServiceController()
 {
     Delegate                   = new ServiceControllerDelegate();
     GoodServiceClient          = new GDServiceClient();
     GoodServiceClient.Delegate = new GreetingsClientGDServiceClientDelegate(this);
     GoodServiceServer          = new GDService();
     GoodServiceServer.Delegate = new GreetingsClientGDServiceDelegate(this);
 }
Example #3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            NavigationController.NavigationBar.Opaque      = true;
            NavigationController.NavigationBar.Translucent = false;
            Title = "Save Edit Service";

            GoodService          = new GDService();
            GoodService.Delegate = new GoodServiceDelegate(this);

            doneButton.Clicked += DoneButton_Clicked;
        }
        private bool ProcessDateAndTimeServiceRequest(string application, string service, string version, string method, Foundation.NSObject parameters, NSObject[] attachments, string requestID, out NSError goodError)
        {
            goodError = null;
            bool didSendResponse = false;

            if (String.Equals(version, "1.0.0"))
            {
                String dateString = DateTime.Now.ToString("g");
                didSendResponse = GDService.ReplyTo(application, new NSString(dateString), GDTForegroundOption.EPreferPeerInForeground, null, requestID, out goodError);
            }

            return(didSendResponse);
        }
Example #5
0
        public void SendErrorTo(string application, NSError error)
        {
            NSError goodError            = null;
            bool    didSendErrorResponse = GDService.ReplyTo(application, error, GDTForegroundOption.EPreferPeerInForeground, null, null, out goodError);

            if (!didSendErrorResponse)
            {
                if (goodError != null)
                {
                    UIAlertView alert = new UIAlertView("Error", goodError.LocalizedDescription, null, "OK", null);
                    alert.Show();
                }
            }
        }
        private bool ProcessGreetingsService(string application, string service, string version, string method, Foundation.NSObject parameters, NSObject[] attachments, string requestID, out NSError goodError)
        {
            goodError = null;
            bool requestProcessed = false;

            if (String.Equals(version, "1.0.0"))
            {
                if (String.Equals(method, "greetMe"))
                {
                    requestProcessed = GDService.ReplyTo(application, new NSString("G'day mate!"), GDTForegroundOption.EPreferPeerInForeground, null, requestID, out goodError);
                }
                else if (String.Equals(method, "sendFiles"))
                {
                    StringBuilder fileString = new StringBuilder(20);
                    GDFileStat    fileStat   = new GDFileStat();
                    for (int i = 0; i < attachments.Length; i++)
                    {
                        NSString file  = (NSString)attachments [i];
                        NSError  error = null;
                        bool     ok    = GDFileSystem.GetFileStat(file, ref fileStat, out error);
                        fileString.AppendFormat("{0}: ", file);

                        if (ok && error == null)
                        {
                            goodError = null;
                            fileString.AppendFormat("{0} bytes; ", fileStat.fileLen);
                            NSData fileData = GDFileSystem.ReadFromFile(file, out error);
                            if (fileData != null && error != null)
                            {
                                Console.WriteLine(String.Format("Filepath: {0}", file));
                                string fileDataString = NSString.FromData(fileData, NSStringEncoding.UTF8);
                                Console.WriteLine(String.Format("File Contents: {0}", fileDataString));
                            }
                        }
                        else
                        {
                            goodError = error;
                            fileString.AppendFormat("Error: {0}", error.LocalizedDescription);
                        }
                    }

                    UIAlertView alertView = new UIAlertView("Recieved Files", fileString.ToString(), null, "OK", null);
                    alertView.Show();
                    requestProcessed = true;
                }
            }

            return(requestProcessed);
        }
Example #7
0
    void Awake()
    {
        GDService service = new GDService();

        service.ProfileEvent += new ProfilerEventHandler(Profile);
        GamedoniaDevices.services.Add(service);

                #if UNITY_EDITOR
                #elif UNITY_ANDROID
        if (debug)
        {
            Debug.Log("[GamedoniaStoreInAppPurchases] StartInAppBilling");
        }
        GamedoniaStore.StartInAppBilling(androidPublickey);
                #endif
    }
Example #8
0
        void DoneButton_Clicked(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(_requestId))
            {
                Console.WriteLine("Service has not connected to client");
                return;
            }

            NSError error = null;
            var     paths = NSSearchPath.GetDirectories(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomain.User,
                                                        true);
            var documentPathForFile = new NSString(paths[0]).AppendPathComponent(
                new NSString("RespondDataFile.txt")).ToString();

            GDFileSystem.WriteToFile(NSData.FromString(textView.Text, NSStringEncoding.UTF8), documentPathForFile,
                                     out error);

            if (error == null)
            {
                var urlString = string.Format("{0}.sc2://", _application);
                var testUrl   = new NSUrl(urlString);
                if (!UIApplication.SharedApplication.CanOpenUrl(testUrl))
                {
                    Console.WriteLine("Client is not installed");
                    return;
                }

                bool replyResult = GDService.ReplyTo(_application, null, GDTForegroundOption.EPreferPeerInForeground,
                                                     new[] { new NSString(documentPathForFile) }, _requestId, out error);

                if (!replyResult)
                {
                    Console.WriteLine("Failed to get Reply");
                }

                if (error != null)
                {
                    Console.WriteLine("Failed to Reply: {0} {1:d} {2}", error.Domain, error.Code,
                                      error.LocalizedDescription);
                }
            }
            else
            {
                Console.WriteLine("Failed to write data to secure storage: {0}", error.LocalizedDescription);
            }
        }
Example #9
0
 public bool ConsumeFrontRequestService(string serviceID, string application, string method, string version)
 {
     if (serviceID.Equals(GoodDynamics.ICCMiscConstants.GDFrontRequestService) && version.Equals("1.0.0.0"))
     {
         if (method.Equals(GoodDynamics.ICCMiscConstants.GDFrontRequestMethod))
         {
             NSError error = null;
             GDService.BringToFront(application, out error);
         }
         else
         {
             NSDictionary errorDetail = new NSDictionary();
             errorDetail.SetValueForKey(new NSString(kMethodNotImplementedDescription), NSError.LocalizedDescriptionKey);
             NSError serviceError = new NSError(ICCErrorConstants.GDServicesErrorDomain, ICCErrorConstants.GDServicesErrorMethodNotFound, errorDetail);
             SendErrorTo(application, serviceError);
         }
         return(true);
     }
     return(false);
 }
Example #10
0
        void ReportError(string application, string requestID, string message, int code)
        {
            var          localizedKey = NSError.LocalizedDescriptionKey;
            NSError      error        = null;
            NSDictionary userInfo     = new NSDictionary();

            userInfo.SetValueForKey(new NSString(message), localizedKey);

            NSError replyParams = new NSError(ICCErrorConstants.GDServicesErrorDomain, code, userInfo);

            bool replyResult = GDService.ReplyTo(application, replyParams, GDTForegroundOption.ENoForegroundPreference,
                                                 null, requestID, out error);

            if (!replyResult)
            {
                Console.WriteLine("ReplyTo returned false");
            }

            if (error != null)
            {
                Console.WriteLine("GDServiceReceiveFrom failed to reply: {0} {1:d} {2}",
                                  error.Domain, error.Code, error.LocalizedDescription);
            }
        }
Example #11
0
 public ServiceController()
 {
     GDService          = new GDService();
     GDService.Delegate = new GreetingsServerGDServiceDelegate(this);
 }
    void Awake()
    {
        GDService service = new GDService();
        service.ProfileEvent += new ProfilerEventHandler(Profile);
        GamedoniaDevices.services.Add(service);

        #if UNITY_EDITOR
        #elif UNITY_ANDROID

        if (debug) Debug.Log("[GamedoniaStoreInAppPurchases] StartInAppBilling");
        GamedoniaStore.StartInAppBilling(androidPublickey);

        #endif
    }