Example #1
0
        static void Main(string[] args)
        {
            var appKey    = "7924946bbbd2fc014135";
            var appId     = "875585";
            var appSecret = "a6c2c1f9ae29637d995a";
            var cluster   = "ap1";

            var pusherServerOptions = new PusherServer.PusherOptions();

            pusherServerOptions.Cluster   = cluster;
            pusherServerOptions.Encrypted = true;

            var pusherClientOptions = new PusherClient.PusherOptions();

            pusherClientOptions.Cluster   = cluster;
            pusherClientOptions.Encrypted = true;

            // Pusher message bus initialization.
            var pusherMessageBus = new PusherLiteMessageBusService(appKey, appId, appSecret, cluster);

            pusherMessageBus
            .HookMessageChannel <Item>(MessageChannelConstants.Ui, MessageEventConstants.SendMessage)
            .Subscribe(message =>
            {
                Console.WriteLine(
                    $"[PUSHER] {DateTime.UtcNow:yyyy-MM-dd HH:mm:ss} - Message received: {message}");
            });

            var m4a1 = new Item(Guid.NewGuid(), "M4A1 Carbine");

            pusherMessageBus.AddMessage(MessageChannelConstants.Ui, MessageEventConstants.SendMessage, m4a1);
            pusherMessageBus.AddMessage(MessageChannelConstants.Ui, MessageEventConstants.SendMessage, m4a1);
            Console.WriteLine($"Sent message");
            Console.ReadLine();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Pusher" /> class.
        /// </summary>
        /// <param name="applicationKey">The application key.</param>
        /// <param name="options">The options.</param>
        public Pusher(string applicationKey, PusherOptions options = null)
        {
            _applicationKey = applicationKey;

            if (options == null)
                _options = new PusherOptions() { Encrypted = false };
            else
                _options = options;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Pusher" /> class.
        /// </summary>
        /// <param name="applicationKey">The application key.</param>
        /// <param name="options">The options.</param>
        public Pusher()
        {
            _applicationKey = PusherSettings.AppKey;
            _options = new PusherOptions();
            _options.Encrypted = PusherSettings.Encrypted;

            if( PusherSettings.HttpAuthUrl.Length > 0 )
                _options.Authorizer = new HttpAuthorizer( PusherSettings.HttpAuthUrl );
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Pusher" /> class.
        /// </summary>
        /// <param name="applicationKey">The application key.</param>
        /// <param name="options">The options.</param>
        public Pusher()
        {
            _applicationKey    = PusherSettings.AppKey;
            _options           = new PusherOptions();
            _options.Encrypted = PusherSettings.Encrypted;

            if (PusherSettings.HttpAuthUrl.Length > 0)
            {
                _options.Authorizer = new HttpAuthorizer(PusherSettings.HttpAuthUrl);
            }
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Pusher" /> class.
        /// </summary>
        /// <param name="applicationKey">The application key.</param>
        /// <param name="options">The options.</param>
        public Pusher(string applicationKey, PusherOptions options = null)
        {
            if (string.IsNullOrWhiteSpace(applicationKey))
            {
                throw new ArgumentException(ErrorConstants.ApplicationKeyNotSet, nameof(applicationKey));
            }

            _applicationKey = applicationKey;

            _options = options ?? new PusherOptions {
                Encrypted = false
            };
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Pusher" /> class.
        /// </summary>
        /// <param name="applicationKey">The application key.</param>
        /// <param name="options">The options.</param>
        public Pusher(string applicationKey, PusherOptions options = null)
        {
            if (string.IsNullOrWhiteSpace(applicationKey))
            {
                throw new ArgumentException(ErrorConstants.ApplicationKeyNotSet, nameof(applicationKey));
            }

            _applicationKey = applicationKey;

            Options = options ?? new PusherOptions();
            ((IPusher)this).PusherOptions = Options;
            SetEventEmitterErrorHandler(InvokeErrorHandler);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="Pusher" /> class.
        /// </summary>
        /// <param name="applicationKey">The application key.</param>
        /// <param name="options">The options.</param>
        public Pusher(string applicationKey, PusherOptions options = null)
        {
            _applicationKey = applicationKey;

            if (options == null)
            {
                _options = new PusherOptions()
                {
                    Encrypted = false
                }
            }
            ;
            else
            {
                _options = options;
            }
        }
Example #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Pusher" /> class.
        /// </summary>
        /// <param name="applicationKey">The application key.</param>
        /// <param name="options">The options.</param>
        public Pusher(string applicationKey, PusherOptions options = null)
        {
            _applicationKey = applicationKey;

            if (options == null)
            {
                _options = new PusherOptions()
                {
                    Encrypted = false
                }
            }
            ;
            else
            {
                _options = options;
            }

            if (PusherSettings.HttpAuthUrl.Length > 0)
            {
                _options.Authorizer = new HttpAuthorizer(PusherSettings.HttpAuthUrl);
            }
        }