Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via XmlDocument.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxRegisterDeviceResponse(string localRequestId, PostboxCallName callName, XmlDocument response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            XmlNode result = response.SelectSingleNode("/PostBoxGlobal/Result");

            if (result != null)
            {
                XmlNode notificationNode = result.SelectSingleNode("NotificationCode");
                if (notificationNode != null)
                {
                    NotificationCode = notificationNode.InnerText;
                }

                XmlNode notificationDescNode = result.SelectSingleNode("NotificationDescription");
                if (notificationDescNode != null)
                {
                    NotificationDescription = notificationDescNode.InnerText;
                }

                XmlNode deviceIdNode = result.SelectSingleNode("DeviceID");
                if (deviceIdNode != null)
                {
                    DeviceId = deviceIdNode.InnerText;
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PostboxResponse"/> class via JSONObject.
 /// </summary>
 /// <param name="localRequestId">localRequest identifier.</param>
 /// <param name="callName">callname of request</param>
 /// <param name="response">response object.</param>
 public PostboxRegisterPlayerResponse(string localRequestId, PostboxCallName callName, JSONObject response) : base(localRequestId, callName, response)
 {
     if (response == null)
     {
         return;
     }
 }
Exemple #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via XmlDocument.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxPingDeviceResponse(string localRequestId, PostboxCallName callName, XmlDocument response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            XmlNode result = response.SelectSingleNode("/PostBoxGlobal/Result");

            if (result != null)
            {
                switch (result.InnerText)
                {
                case "server":
                    PingStatus = PostboxPingStatus.server;
                    break;

                case "device":
                    PingStatus = PostboxPingStatus.device;
                    break;

                default:
                    break;
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via JSONObject.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxGetDataPackagesResponse(string localRequestId, PostboxCallName callName, JSONObject response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            JSONObject result = response.GetField("Result");

            if (result != null)
            {
                List <JSONObject> requestNodes = result.list;

                if (requestNodes != null && requestNodes.Count > 0)
                {
                    packages = new PostboxDataPackage[requestNodes.Count];

                    for (int i = 0; i < packages.Length; i++)
                    {
                        JSONObject request = requestNodes[i].GetField("Request");

                        // create object
                        packages[i] = new PostboxDataPackage(request.GetField("TransactionId").str,
                                                             request.GetField("SenderAppId").str,
                                                             request.GetField("SenderDeviceId").str,
                                                             request.GetField("CreatedAt").str,
                                                             request.GetField("UpdatedAt").str,
                                                             request.GetField("Status").str,
                                                             request.GetField("Data").str);
                    }
                }
            }
        }
Exemple #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PostboxResponse"/> class via JSONObject.
 /// </summary>
 /// <param name="localRequestId">localRequest identifier.</param>
 /// <param name="callName">callname of request</param>
 /// <param name="response">response object.</param>
 public PostboxPingDeviceResponse(string localRequestId, PostboxCallName callName, JSONObject response) : base(localRequestId, callName, response)
 {
     if (response == null)
     {
         return;
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via XmlDocument.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxGetFriendlistResponse(string localRequestId, PostboxCallName callName, XmlDocument response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            XmlNode result = response.SelectSingleNode("/PostBoxGlobal/Result");

            if (result != null)
            {
                // --- Friends ---
                XmlNode     friendsNode = result.SelectSingleNode("Friends");
                XmlNodeList friendNodes = friendsNode.ChildNodes;

                if (friendNodes.Count > 0)
                {
                    Friends = new PostboxDevicePackage[friendNodes.Count];

                    for (int i = 0; i < Friends.Length; i++)
                    {
                        // create object
                        Friends[i] = new PostboxDevicePackage(friendNodes[i].Attributes.GetNamedItem("public_device_id").InnerText,
                                                              friendNodes[i].Attributes.GetNamedItem("model").InnerText,
                                                              friendNodes[i].Attributes.GetNamedItem("type").InnerText,
                                                              friendNodes[i].Attributes.GetNamedItem("os").InnerText,
                                                              friendNodes[i].Attributes.GetNamedItem("created_at").InnerText,
                                                              friendNodes[i].Attributes.GetNamedItem("status").InnerText);
                    }
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via JSONObject.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxServerTimeResponse(string localRequestId, PostboxCallName callName, JSONObject response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            JSONObject result = response.GetField("Result");

            if (result != null)
            {
                try
                {
                    Timestamp = Convert.ToDateTime(result.GetField("TimeStamp").str);
                }
                catch (FormatException ex)
                {
                    Timestamp = null;
                }

                try
                {
                    UniversalTimeStamp = Convert.ToDateTime(result.GetField("UniversalTimeStamp").str);
                }
                catch (FormatException ex)
                {
                    UniversalTimeStamp = null;
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via XmlDocument.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxServerTimeResponse(string localRequestId, PostboxCallName callName, XmlDocument response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            XmlNode result = response.SelectSingleNode("/PostBoxGlobal/Result");

            if (result != null)
            {
                try
                {
                    XmlNode timeStampNode = result.SelectSingleNode("TimeStamp");
                    Timestamp = Convert.ToDateTime(timeStampNode.InnerText);
                }
                catch (FormatException ex)
                {
                    Timestamp = null;
                }

                try
                {
                    XmlNode universalTimeStampNode = result.SelectSingleNode("UniversalTimeStamp");
                    UniversalTimeStamp = Convert.ToDateTime(universalTimeStampNode.InnerText);
                }
                catch (FormatException ex)
                {
                    UniversalTimeStamp = null;
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via JSONObject.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxRegisterDeviceResponse(string localRequestId, PostboxCallName callName, JSONObject response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            JSONObject result = response.GetField("Result");

            if (result != null)
            {
                if (result.GetField("DeviceID") != null)
                {
                    DeviceId = result.GetField("DeviceID").str;
                }

                if (result.GetField("NotificationCode") != null)
                {
                    NotificationCode = result.GetField("NotificationCode").str;
                }

                if (result.GetField("NotificationDescription") != null)
                {
                    NotificationDescription = result.GetField("NotificationDescription").str;
                }
            }
        }
Exemple #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via JSONObject.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxUpdateDataPackageResponse(string localRequestId, PostboxCallName callName, JSONObject response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            JSONObject result = response.GetField("Result");
        }
Exemple #11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via XmlDocument.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxUpdateDataPackageResponse(string localRequestId, PostboxCallName callName, XmlDocument response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            XmlNode result = response.SelectSingleNode("/PostboxGlobal/Result");
        }
Exemple #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class.
        /// </summary>
        /// <param name="localRequestId">local transaction identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">XmlDocument</param>
        public PostboxResponse(string localRequestId, PostboxCallName callName, XmlDocument response)
        {
            LocalRequestId = localRequestId;
            CallName       = callName;
            XMLObject      = response;

            if (response != null)
            {
                // PostboxGlobal-Node
                XmlNode postBoxGlobal = response.SelectSingleNode("PostBoxGlobal");

                if (postBoxGlobal != null)
                {
                    XmlNode callNamenNode = postBoxGlobal.SelectSingleNode("CallName");
                    CallName = CallNameStringToEnum(callNamenNode.InnerText);

                    XmlNode callStatusNode = postBoxGlobal.SelectSingleNode("CallStatus");
                    CallStatus = CallStatusStringToEnum(callStatusNode.InnerText);

                    XmlNode versionNode = postBoxGlobal.SelectSingleNode("Version");
                    Version = versionNode.InnerText;

                    // Error-Node
                    XmlNode errorList = postBoxGlobal.SelectSingleNode("ErrorList");

                    if (errorList != null)
                    {
                        XmlNodeList errorNodes = errorList.ChildNodes;

                        if (errorNodes.Count > 0)
                        {
                            Errors = new Dictionary <PostboxAPIErrorCode, PostboxAPIError>(errorNodes.Count);

                            for (int i = 0; i < errorNodes.Count; i++)
                            {
                                XmlNode errorCodeNode            = errorNodes[i].SelectSingleNode("ErrorCode");
                                XmlNode errorDescriptionNode     = errorNodes[i].SelectSingleNode("ErrorDescription");
                                XmlNode errorLongDescriptionNode = errorNodes[i].SelectSingleNode("ErrorLongDescription");

                                PostboxAPIError apiError = new PostboxAPIError(errorCodeNode.InnerText,
                                                                               errorDescriptionNode.InnerText,
                                                                               errorLongDescriptionNode.InnerText);

                                Errors.Add(apiError.ErrorCode, apiError);
                            }
                        }
                    }
                }
            }
            else
            {
                // If result is Empty
                CreateNoConnectionError();
            }
        }
Exemple #13
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class.
        /// </summary>
        /// <param name="localRequestId">local transaction identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">JSONObject</param>
        public PostboxResponse(string localRequestId, PostboxCallName callName, JSONObject response)
        {
            LocalRequestId = localRequestId;
            CallName       = callName;
            JSONObject     = response;

            if (response != null)
            {
                // PostboxGlobal-Node
                JSONObject postBoxGlobal = response;

                if (postBoxGlobal != null)
                {
                    CallName   = CallNameStringToEnum(postBoxGlobal.GetField("CallName").str);
                    CallStatus = CallStatusStringToEnum(postBoxGlobal.GetField("CallStatus").str);
                    Version    = postBoxGlobal.GetField("Version").str;
                }

                // Error-Node
                JSONObject errorListNode = response.GetField("ErrorList");

                if (errorListNode != null && errorListNode.IsArray)
                {
                    List <JSONObject> errorList = errorListNode.list;

                    if (errorList.Count > 0)
                    {
                        Errors = new Dictionary <PostboxAPIErrorCode, PostboxAPIError>(errorList.Count);

                        for (int i = 0; i < errorList.Count; i++)
                        {
                            JSONObject error = errorList[i].GetField("Error");

                            if (error != null)
                            {
                                JSONObject errorCodeNode            = error.GetField("ErrorCode");
                                JSONObject errorDescriptionNode     = error.GetField("ErrorDescription");
                                JSONObject errorLongDescriptionNode = error.GetField("ErrorLongDescription");

                                PostboxAPIError apiError = new PostboxAPIError(errorCodeNode.i.ToString(),
                                                                               errorDescriptionNode.str,
                                                                               errorLongDescriptionNode.str);
                                Errors.Add(apiError.ErrorCode, apiError);
                            }
                        }
                    }
                }
            }
            else
            {
                // If result is Empty
                CreateNoConnectionError();
            }
        }
Exemple #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via JSONObject.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxCheckAppIDResponse(string localRequestId, PostboxCallName callName, JSONObject response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            JSONObject result = response.GetField("Result");

            if (result != null)
            {
                Status = Convert.ToBoolean(result.str);
            }
        }
Exemple #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via XmlDocument.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxCheckAppIDResponse(string localRequestId, PostboxCallName callName, XmlDocument response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            XmlNode result = response.SelectSingleNode("/PostBoxGlobal/Result");

            if (result != null)
            {
                Status = Convert.ToBoolean(result.InnerText);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via JSONObject.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxSendDataPackageToDeviceResponse(string localRequestId, PostboxCallName callName, JSONObject response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            JSONObject result = response.GetField("Result");

            if (result != null)
            {
                TransactionId = result.GetField("TransactionId").str;
            }
        }
Exemple #17
0
        /// <summary>
        /// Assign the call name of the given string
        /// </summary>
        /// <param name="callName">callname string</param>
        /// <returns>PostboxCallName</returns>
        public static PostboxCallName CallNameStringToEnum(string callName)
        {
            PostboxCallName output = PostboxCallName.NotFound;

            if (Enum.IsDefined(typeof(PostboxCallName), callName))
            {
                output = (PostboxCallName)Enum.Parse(typeof(PostboxCallName), callName);
            }
            else
            {
                PostboxLogbook.Instance.Log("CallName '" + callName + "' can't be converted. Not vaild.", PostboxLogbook.NotificationType.Error);
            }

            return(output);
        }
Exemple #18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via JSONObject.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxAddToFriendlistResponse(string localRequestId, PostboxCallName callName, JSONObject response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            JSONObject result = response.GetField("Result");

            if (result != null)
            {
                NotificationCode        = result.GetField("NotificationCode").str;
                NotificationDescription = result.GetField("NotificationDescription").str;
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via XmlDocument.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxSendDataPackageToDeviceResponse(string localRequestId, PostboxCallName callName, XmlDocument response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            XmlNode result = response.SelectSingleNode("/PostBoxGlobal/Result");

            if (result != null)
            {
                XmlNode transactionIdNode = result.SelectSingleNode("TransactionId");
                TransactionId = transactionIdNode.InnerText;
            }
        }
Exemple #20
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via XmlDocument.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxGetDataPackageStatusResponse(string localRequestId, PostboxCallName callName, XmlDocument response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            XmlNode result = response.SelectSingleNode("/PostBoxGlobal/Result");

            if (result != null)
            {
                XmlNode statusNode = result.SelectSingleNode("Status");
                Status = StatusStringToEnum(statusNode.InnerText);

                XmlNode notificationNode = result.SelectSingleNode("Notification");
                Notification = notificationNode.InnerText;
            }
        }
Exemple #21
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via JSONObject.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxGetDataPackageStatusResponse(string localRequestId, PostboxCallName callName, JSONObject response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            JSONObject result = response.GetField("Result");

            if (result != null)
            {
                Status = StatusStringToEnum(result.GetField("Status").str);

                if (result.GetField("Notification") != null)
                {
                    Notification = result.GetField("Notification").str;
                }
            }
        }
Exemple #22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via XmlDocument.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxGetDataPackagesResponse(string localRequestId, PostboxCallName callName, XmlDocument response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            XmlNode result = response.SelectSingleNode("/PostBoxGlobal/Result");

            if (result != null)
            {
                XmlNodeList requestNodes = result.ChildNodes;

                if (requestNodes.Count > 0)
                {
                    packages = new PostboxDataPackage[requestNodes.Count];

                    for (int i = 0; i < packages.Length; i++)
                    {
                        // list parameters
                        //XmlNodeList parameterNodes = requestNodes[i].SelectSingleNode("Params").ChildNodes;
                        //PostboxCallParameter[] parameters = new PostboxCallParameter[parameterNodes.Count];

                        /*
                         * for (int y = 0; y < parameterNodes.Count; y++)
                         * {
                         *  parameters[y] = new PostboxCallParameter(parameterNodes.Item(y).Name, parameterNodes.Item(y).InnerText);
                         * }*/

                        // create object
                        packages[i] = new PostboxDataPackage(requestNodes[i].SelectSingleNode("TransactionId").InnerText,
                                                             requestNodes[i].SelectSingleNode("SenderAppId").InnerText,
                                                             requestNodes[i].SelectSingleNode("SenderDeviceId").InnerText,
                                                             requestNodes[i].SelectSingleNode("CreatedAt").InnerText,
                                                             requestNodes[i].SelectSingleNode("UpdatedAt").InnerText,
                                                             requestNodes[i].SelectSingleNode("Status").InnerText,
                                                             requestNodes[i].SelectSingleNode("Data").InnerText);
                    }
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PostboxResponse"/> class via JSONObject.
        /// </summary>
        /// <param name="localRequestId">localRequest identifier.</param>
        /// <param name="callName">callname of request</param>
        /// <param name="response">response object.</param>
        public PostboxGetFriendlistResponse(string localRequestId, PostboxCallName callName, JSONObject response) : base(localRequestId, callName, response)
        {
            if (response == null)
            {
                return;
            }

            JSONObject result = response.GetField("Result");

            if (result != null)
            {
                // --- Friends ---
                JSONObject requestsNode = result.GetField("Friends");

                if (requestsNode != null & requestsNode.IsArray)
                {
                    List <JSONObject> requestNodes = requestsNode.list;

                    if (requestNodes != null && requestNodes.Count > 0)
                    {
                        Friends = new PostboxDevicePackage[requestNodes.Count];

                        for (int i = 0; i < Friends.Length; i++)
                        {
                            JSONObject request = requestNodes[i].GetField("Friend");

                            // create object
                            Friends[i] = new PostboxDevicePackage(request.GetField("public_device_id").str,
                                                                  request.GetField("model").str,
                                                                  request.GetField("type").str,
                                                                  request.GetField("os").str,
                                                                  request.GetField("created_at").str,
                                                                  request.GetField("status").str);
                        }
                    }
                }
            }
        }