예제 #1
0
        /// <summary>
        /// Sends a message to a player from the currently logged-in Player. A message can
        /// transfer Currency and Inventory items between players. Direct access to this
        /// method from the SDKs is disabled by default and must be enabled from the
        /// ChilliConnect dashboard. Note: At least one of; Title, Text, Data, or Rewards is
        /// required.
        /// </summary>
        ///
        /// <param name="desc">The request description.</param>
        /// <param name="successCallback">The delegate which is called if the request was successful.</param>
        /// <param name="errorCallback">The delegate which is called if the request was unsuccessful. Provides
        /// a container with information on what went wrong.</param>
        public void SendMessageFromPlayer(SendMessageFromPlayerRequestDesc desc, Action <SendMessageFromPlayerRequest, SendMessageFromPlayerResponse> successCallback, Action <SendMessageFromPlayerRequest, SendMessageFromPlayerError> errorCallback)
        {
            m_logging.LogVerboseMessage("Sending Send Message From Player request.");

            var connectAccessToken = m_dataStore.GetString("UserAccessToken");
            var request            = new SendMessageFromPlayerRequest(desc, connectAccessToken);

            m_serverRequestSystem.SendImmediateRequest(request, (IImmediateServerRequest sentRequest, ServerResponse serverResponse) =>
            {
                ReleaseAssert.IsTrue(request == sentRequest, "Received request is not the same as the one sent!");

                if (serverResponse.Result == HttpResult.Success && serverResponse.HttpResponseCode == SuccessHttpResponseCode)
                {
                    NotifySendMessageFromPlayerSuccess(serverResponse, request, successCallback);
                }
                else
                {
                    NotifySendMessageFromPlayerError(serverResponse, request, errorCallback);
                }
            });
        }
예제 #2
0
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        public SendMessageFromPlayerRequest(SendMessageFromPlayerRequestDesc desc, string connectAccessToken)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.To, "To cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            To    = desc.To;
            Title = desc.Title;
            Text  = desc.Text;
            Data  = desc.Data;
            if (desc.Tags != null)
            {
                Tags = Mutability.ToImmutable(desc.Tags);
            }
            Expiry             = desc.Expiry;
            Transfer           = desc.Transfer;
            ConnectAccessToken = connectAccessToken;

            Url = "https://connect.chilliconnect.com/1.0/message/player/send";
            HttpRequestMethod = HttpRequestMethod.Post;
        }