Ejemplo n.º 1
0
 public Emitter handleEmitAck(string Event, object Object, Ackcall ack)
 {
     if (singleackcallbacks.ContainsKey(Event))
     {
         AckListener listener = singleackcallbacks[Event];
         listener(Event, Object, ack);
     }
     return(this);
 }
Ejemplo n.º 2
0
        public Emitter HandleEmitAck(string Event, object Object, Ackcall ack)
        {
            if (!_singleackcallbacks.ContainsKey(Event))
            {
                return(this);
            }
            var listener = _singleackcallbacks[Event];

            listener(Event, Object, ack);
            return(this);
        }
        public bool Emit(string Event, object Object, Ackcall ack)
        {
            Log($"Emit with ack invoked, Event {Event}, Object {Object}, ACK {ack.GetMethodInfo().Name}.");
            var count       = Interlocked.Increment(ref _counter);
            var eventObject = new Dictionary <string, object> {
                { "event", Event }, { "data", Object }, { "cid", count }
            };

            _acks.Add(count, GetAckObject(Event, ack));
            var json = _options.Serializer.Serialize(eventObject);

            return(_socket.Send(json));
        }
Ejemplo n.º 4
0
        public Socket unsubscribe(string Channel, Ackcall ack)
        {
            long count = Interlocked.Increment(ref counter);
            Dictionary <string, object> subscribeObject = new Dictionary <string, object> {
                { "event", "#unsubscribe" }, { "data", Channel }, { "cid", count }
            };

            acks.Add(count, getAckObject(Channel, ack));
            var json = JsonConvert.SerializeObject(subscribeObject, Formatting.Indented);

            _socket.Send(json);
            return(this);
        }
Ejemplo n.º 5
0
        public Socket emit(string Event, object Object, Ackcall ack)
        {
            long count = Interlocked.Increment(ref counter);
            Dictionary <string, object> eventObject = new Dictionary <string, object> {
                { "event", Event }, { "data", Object }, { "cid", count }
            };

            acks.Add(count, getAckObject(Event, ack));
            var json = JsonConvert.SerializeObject(eventObject, Formatting.Indented);

            _socket.Send(json);
            return(this);
        }
Ejemplo n.º 6
0
        public Socket Unsubscribe(string channel, Ackcall ack)
        {
            long count = Interlocked.Increment(ref _counter);
            Dictionary <string, object> subscribeObject =
                new Dictionary <string, object> {
                { "event", "#unsubscribe" }, { "data", channel }, { "cid", count }
            };

            acks.Add(count, GetAckObject(channel, ack));
            var json = JsonMapper.ToJson(subscribeObject);

            _socket.Send(json);
            return(this);
        }
Ejemplo n.º 7
0
        public Socket Emit(string Event, object Object, Ackcall ack)
        {
            long count = Interlocked.Increment(ref _counter);
            Dictionary <string, object> eventObject =
                new Dictionary <string, object> {
                { "event", Event }, { "data", Object }, { "cid", count }
            };

            acks.Add(count, GetAckObject(Event, ack));
            var json = JsonMapper.ToJson(eventObject);

            _socket.Send(json);
            return(this);
        }
        public bool Unsubscribe(string channel, Ackcall ack)
        {
            Log($"Unsubscribe with ACK invoked, Channel {channel}, ACK {ack.GetMethodInfo().Name}.");
            var count           = Interlocked.Increment(ref _counter);
            var subscribeObject = new Dictionary <string, object>
            {
                { "event", "#unsubscribe" },
                { "data", channel },
                { "cid", count }
            };

            _acks.Add(count, GetAckObject(channel, ack));
            var json = _options.Serializer.Serialize(subscribeObject);

            return(_socket.Send(json));
        }
        public bool Publish(string channel, object data, Ackcall ack)
        {
            Log($"Publish with ACK invoked, Channel {channel}, Data {data}, ACK {ack.GetMethodInfo().Name}.");
            var count         = Interlocked.Increment(ref _counter);
            var publishObject = new Dictionary <string, object>
            {
                { "event", "#publish" },
                { "data", new Dictionary <string, object> {
                      { "channel", channel }, { "data", data }
                  } },
                { "cid", count }
            };

            _acks.Add(count, GetAckObject(channel, ack));
            var json = _options.Serializer.Serialize(publishObject);

            return(_socket.Send(json));
        }
Ejemplo n.º 10
0
        public Socket Publish(string channel, object data, Ackcall ack)
        {
            long count = Interlocked.Increment(ref _counter);
            Dictionary <string, object> publishObject = new Dictionary <string, object>
            {
                { "event", "#publish" },
                { "data", new Dictionary <string, object> {
                      { "channel", channel }, { "data", data }
                  } },
                { "cid", count }
            };

            acks.Add(count, GetAckObject(channel, ack));
            var json = JsonMapper.ToJson(publishObject);

            _socket.Send(json);
            return(this);
        }
Ejemplo n.º 11
0
 public void Unsubscribe(Ackcall ack)
 {
     _socket.Unsubscribe(_channelname, ack);
     _socket._channels.Remove(this);
 }
Ejemplo n.º 12
0
 public void unsubscribe(Ackcall ack)
 {
     socket.unsubscribe(Channelname, ack);
     socket.channels.Remove(this);
 }
Ejemplo n.º 13
0
 public void publish(object data, Ackcall ack)
 {
     socket.publish(Channelname, data, ack);
 }
Ejemplo n.º 14
0
 public Channel subscribe(Ackcall ack)
 {
     socket.subscribe(Channelname, ack);
     return(this);
 }
Ejemplo n.º 15
0
 private object[] getAckObject(string Event, Ackcall ack)
 {
     object [] Object = { Event, ack };
     return(Object);
 }
Ejemplo n.º 16
0
 public void Publish(object data, Ackcall ack)
 {
     _socket.Publish(_channelname, data, ack);
 }
Ejemplo n.º 17
0
 public Channel Subscribe(Ackcall ack)
 {
     _socket.Subscribe(_channelname, ack);
     return(this);
 }
 private static object[] GetAckObject(string Event, Ackcall ack) => new object[]
 {
     Event, ack
 };