Example #1
0
        protected override void RunWebRequest(QueueManager qm)
        {
            RequestState requestState = new RequestState();

            requestState.OperationType = OperationType;

            var publishFileMessage = new {
                message = new {
                    text = PublishFileMessage,
                },
                file = new {
                    name = PublishFileMessageFileName,
                    id   = PublishFileID,
                },
            };

            string jsonMessage  = (publishFileMessageAsIs) ? publishFileMessage.ToString() : Helpers.JsonEncodePublishMsg(publishFileMessage, this.PubNubInstance.PNConfig.CipherKey, this.PubNubInstance.JsonLibrary, this.PubNubInstance.PNLog);
            string jsonMetadata = string.Empty;

            if (this.Metadata != null)
            {
                jsonMetadata = Helpers.JsonEncodePublishMsg(this.Metadata, "", this.PubNubInstance.JsonLibrary, this.PubNubInstance.PNLog);
            }

            if (UsePostMethod)
            {
                requestState.httpMethod = HTTPMethod.Post;
                requestState.POSTData   = jsonMessage;
            }
            Uri request = BuildRequests.BuildPublishFileMessageRequest(
                this.PublishFileMessageChannel,
                jsonMessage,
                this.ShouldStoreInHistory,
                jsonMetadata,
                publishFileMessageCounter,
                this.PublishFileMessageTTL,
                UsePostMethod,
                this.ReplicateMessage,
                this.PubNubInstance,
                this.QueryParams
                );

            base.RunWebRequest(qm, request, requestState, this.PubNubInstance.PNConfig.NonSubscribeTimeout, 0, this);
        }