Subscribe() public méthode

public Subscribe ( string channelName ) : Channel
channelName string
Résultat Channel
Exemple #1
0
        public Gateway()
        {
            PusherClient.Pusher pusher = new PusherClient.Pusher("7b4abaf489e799ceeceb");

            Channel alarmChannel = pusher.Subscribe("alarms");
            Channel cmdChannel   = pusher.Subscribe("commands");

            alarmChannel.Bind("ack", (dynamic data) =>
            {
                try
                {
                    EventAcknowled(data);
                }
                catch (Exception ex)
                {
                    var e = ex;
                }
            });

            cmdChannel.Bind("action", (dynamic data) =>
            {
                try
                {
                    EventCommand(data);
                }
                catch (Exception ex)
                {
                    var e = ex;
                }
            });

            pusher.Connect();
        }
        private static void InitPusher()
        {
            _pusher = new Pusher("7899dd5cb232af88083d", new PusherOptions(){
                Authorizer = new HttpAuthorizer("http://localhost:8888/auth/" + HttpUtility.UrlEncode(_name))
            });
            _pusher.ConnectionStateChanged += _pusher_ConnectionStateChanged;
            _pusher.Error += _pusher_Error;

            // Setup private channel
            _chatChannel = _pusher.Subscribe("private-channel");
            _chatChannel.Subscribed += _chatChannel_Subscribed;

            // Inline binding!
            _chatChannel.Bind("client-my-event", (dynamic data) =>
            {
                Console.WriteLine("[" + data.name + "] " + data.message);
            });

            // Setup presence channel
            _presenceChannel = (PresenceChannel)_pusher.Subscribe("presence-channel");
            _presenceChannel.Subscribed += _presenceChannel_Subscribed;
            _presenceChannel.MemberAdded += _presenceChannel_MemberAdded;
            _presenceChannel.MemberRemoved += _presenceChannel_MemberRemoved;

            _pusher.Connect();
        }
Exemple #3
0
        public Gateway()
        {
            PusherClient.Pusher pusher = new PusherClient.Pusher("7b4abaf489e799ceeceb");

            Channel alarmChannel = pusher.Subscribe("alarms");
            Channel cmdChannel = pusher.Subscribe("commands");

            alarmChannel.Bind("ack", (dynamic data) =>
            {
                try
                {
                    EventAcknowled(data);
                }
                catch (Exception ex)
                {
                    var e = ex;
                }

            });

            cmdChannel.Bind("action", (dynamic data) =>
            {
                try
                {
                    EventCommand(data);
                }
                catch (Exception ex)
                {
                    var e = ex;
                }

            });

            pusher.Connect();
        }
Exemple #4
0
        public StampSocket(Action<dynamic> msgHandler)
        {
            _msgHandler = msgHandler;

            _pusher = new Pusher(_key);
            _pusher.ConnectionStateChanged += ConnectionStateChanged;
            _pusher.Error += Error;

            _orderBookChannel = _pusher.Subscribe("order_book");
            _orderBookChannel.Subscribed += OrderBookSubscribed;
            _orderBookChannel.Bind("data", _msgHandler);
        }
        public void Subscribe(string channel, string eventName)
        {
            CheckInitialization("Subscribe");

            PusherClient.Channel chatChannel = pusherClient.Subscribe(channel);
            chatChannel.Bind(eventName, (dynamic data) =>
            {
                var message = Convert.ToString(data);
                Log($"[{channel}][{eventName}]: {message}");

                if (onSubscribedEventMessage != null)
                {
                    onSubscribedEventMessage(channel, eventName, message);
                }
            });
        }
Exemple #6
0
 void HandleConnected(object sender)
 {
     Debug.Log("Pusher client connected, now subscribing to private channel");
     pusherChannel = pusherClient.Subscribe("core_items");
     pusherChannel.BindAll(HandleChannelEvent);
 }