示例#1
0
        public void Publish(object message, string channelName, Messaging.PublishOptions publishOptions,
                            Messaging.DeliveryOptions deliveryOptions, AsyncCallback <MessageStatus> callback)
        {
            checkChannelName(channelName);

            if (message == null)
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_MESSAGE);
            }

            Invoker.InvokeAsync(Invoker.Api.MESSAGINGSERVICE_PUBLISH, new object[] { GetPublishRequestData(message, publishOptions, deliveryOptions), channelName }, callback);
        }
示例#2
0
        public void Publish(object message, string channelName, Messaging.PublishOptions publishOptions,
                            Messaging.DeliveryOptions deliveryOptions, AsyncCallback <MessageStatus> callback)
        {
            checkChannelName(channelName);

            if (message == null)
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_MESSAGE);
            }

            Invoker.InvokeAsync(MESSAGING_MANAGER_SERVER_ALIAS, "publish",
                                new[]
                                { channelName, message, publishOptions, deliveryOptions }, callback);
        }
示例#3
0
        private Messaging.MessageStatus PublishSync(object message, string channelName,
                                                    Messaging.PublishOptions publishOptions,
                                                    Messaging.DeliveryOptions deliveryOptions)
        {
            checkChannelName(channelName);

            if (message == null)
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_MESSAGE);
            }

            return(Invoker.InvokeSync <Messaging.MessageStatus>(MESSAGING_MANAGER_SERVER_ALIAS, "publish",
                                                                new[]
                                                                { channelName, message, publishOptions, deliveryOptions }));
        }
示例#4
0
 public void Publish(object message, string channelName, Messaging.PublishOptions publishOptions,
                     AsyncCallback <MessageStatus> callback)
 {
     Publish(message, channelName, publishOptions, null, callback);
 }
示例#5
0
 public Messaging.MessageStatus Publish(object message, string channelName, Messaging.PublishOptions publishOptions,
                                        Messaging.DeliveryOptions deliveryOptions)
 {
     return(PublishSync(message, channelName, publishOptions, deliveryOptions));
 }
示例#6
0
 public void Publish(object message, Messaging.PublishOptions publishOptions,
                     Messaging.DeliveryOptions deliveryOptions,
                     AsyncCallback <MessageStatus> callback)
 {
     Publish(message, DEFAULT_CHANNEL_NAME, publishOptions, deliveryOptions, callback);
 }
示例#7
0
 public Messaging.MessageStatus Publish(object message, Messaging.PublishOptions publishOptions,
                                        Messaging.DeliveryOptions deliveryOptions)
 {
     return(Publish(message, DEFAULT_CHANNEL_NAME, publishOptions, deliveryOptions));
 }
示例#8
0
        private static Dictionary <string, object> GetPublishRequestData(object message, Messaging.PublishOptions publishOptions, Messaging.DeliveryOptions deliveryOptions)
        {
            Dictionary <string, object> requestData = new Dictionary <string, object>();

            requestData.Add("message", message);
            if (publishOptions != null)
            {
                if (string.IsNullOrEmpty(publishOptions.PublisherId) == false)
                {
                    requestData.Add("publisherId", publishOptions.PublisherId);
                }
                if (publishOptions.Headers != null && publishOptions.Headers.Count > 0)
                {
                    requestData.Add("headers", publishOptions.Headers);
                }
                if (string.IsNullOrEmpty(publishOptions.Subtopic) == false)
                {
                    requestData.Add("subtopic", publishOptions.Subtopic);
                }
            }

            if (deliveryOptions != null)
            {
                if (string.IsNullOrEmpty(deliveryOptions.PushPolicy.ToString()) == false)
                {
                    requestData.Add("pushPolicy", deliveryOptions.PushPolicy.ToString());
                }

                string pushBroadcastStr = "";
                if (deliveryOptions.PushBroadcast == DeliveryOptions.ALL)
                {
                    pushBroadcastStr = "ALL";
                }
                else
                {
                    if ((deliveryOptions.PushBroadcast & DeliveryOptions.IOS) > 0)
                    {
                        pushBroadcastStr = "IOS";
                    }
                    if ((deliveryOptions.PushBroadcast & DeliveryOptions.ANDROID) > 0)
                    {
                        if (string.IsNullOrEmpty(pushBroadcastStr) == false)
                        {
                            pushBroadcastStr += "|";
                        }
                        pushBroadcastStr = "ANDROID";
                    }
                    if ((deliveryOptions.PushBroadcast & DeliveryOptions.WP) > 0)
                    {
                        if (string.IsNullOrEmpty(pushBroadcastStr) == false)
                        {
                            pushBroadcastStr += "|";
                        }
                        pushBroadcastStr = "WP";
                    }
                }
                requestData.Add("pushBroadcast", pushBroadcastStr);

                if (deliveryOptions.PushSinglecast != null && deliveryOptions.PushSinglecast.Count > 0)
                {
                    requestData.Add("pushSinglecast", deliveryOptions.PushSinglecast);
                }

                if (deliveryOptions.PublishAt != null)
                {
                    requestData.Add("publishAt", deliveryOptions.PublishAt.Value.Ticks);
                }

                if (deliveryOptions.RepeatEvery > 0)
                {
                    requestData.Add("repeatEvery", deliveryOptions.RepeatEvery);
                }

                if (deliveryOptions.RepeatExpiresAt != null)
                {
                    requestData.Add("repeatExpiresAt", deliveryOptions.RepeatExpiresAt.Value.Ticks);
                }
            }

            return(requestData);
        }
示例#9
0
        private Messaging.MessageStatus PublishSync(object message, string channelName, Messaging.PublishOptions publishOptions,
                                                    Messaging.DeliveryOptions deliveryOptions)
        {
            checkChannelName(channelName);

            if (message == null)
            {
                throw new ArgumentNullException(ExceptionMessage.NULL_MESSAGE);
            }

            return(Invoker.InvokeSync <Messaging.MessageStatus>(Invoker.Api.MESSAGINGSERVICE_PUBLISH, new object[] { GetPublishRequestData(message, publishOptions, deliveryOptions), channelName }));
        }