Exemplo n.º 1
0
        public void Call(Packet packet)
        {
            string text  = packet.DecodeEventName();
            string text2 = (packet.SocketIOEvent == SocketIOEventTypes.Unknown) ? EventNames.GetNameFor(packet.TransportEvent) : EventNames.GetNameFor(packet.SocketIOEvent);

            object[] args = null;
            if (!this.HasSubsciber(text) && !this.HasSubsciber(text2))
            {
                return;
            }
            if (packet.TransportEvent == TransportEventTypes.Message && (packet.SocketIOEvent == SocketIOEventTypes.Event || packet.SocketIOEvent == SocketIOEventTypes.BinaryEvent) && this.ShouldDecodePayload(text))
            {
                args = packet.Decode(this.Socket.Manager.Encoder);
            }
            if (!string.IsNullOrEmpty(text))
            {
                this.Call(text, packet, args);
            }
            if (!packet.IsDecoded && this.ShouldDecodePayload(text2))
            {
                args = packet.Decode(this.Socket.Manager.Encoder);
            }
            if (!string.IsNullOrEmpty(text2))
            {
                this.Call(text2, packet, args);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This function will get the eventName from the packet's Payload, and optionally will decode it from Json.
        /// </summary>
        public void Call(Packet packet)
        {
            string eventName = packet.DecodeEventName();
            string typeName  = packet.SocketIOEvent != SocketIOEventTypes.Unknown ? EventNames.GetNameFor(packet.SocketIOEvent) : EventNames.GetNameFor(packet.TransportEvent);

            object[] args = null;

            if (!HasSubsciber(eventName) && !HasSubsciber(typeName))
            {
                return;
            }

            // If this is an Event or BinaryEvent message, or we have a subscriber with AutoDecodePayload, then
            //  we have to decode the packet's Payload.
            if (packet.TransportEvent == TransportEventTypes.Message && (packet.SocketIOEvent == SocketIOEventTypes.Event || packet.SocketIOEvent == SocketIOEventTypes.BinaryEvent) && ShouldDecodePayload(eventName))
            {
                args = packet.Decode(Socket.Manager.Encoder);
            }

            // call event callbacks registered for 'eventName'
            if (!string.IsNullOrEmpty(eventName))
            {
                Call(eventName, packet, args);
            }

            if (!packet.IsDecoded && ShouldDecodePayload(typeName))
            {
                args = packet.Decode(Socket.Manager.Encoder);
            }

            // call event callbacks registered for 'typeName'
            if (!string.IsNullOrEmpty(typeName))
            {
                Call(typeName, packet, args);
            }
        }
Exemplo n.º 3
0
        public void Call(Packet packet)
        {
            string eventName = packet.DecodeEventName();
            string str2      = (packet.SocketIOEvent == SocketIOEventTypes.Unknown) ? EventNames.GetNameFor(packet.TransportEvent) : EventNames.GetNameFor(packet.SocketIOEvent);

            object[] args = null;
            if (this.HasSubsciber(eventName) || this.HasSubsciber(str2))
            {
                if (((packet.TransportEvent == TransportEventTypes.Message) && ((packet.SocketIOEvent == SocketIOEventTypes.Event) || (packet.SocketIOEvent == SocketIOEventTypes.BinaryEvent))) && this.ShouldDecodePayload(eventName))
                {
                    args = packet.Decode(this.Socket.Manager.Encoder);
                }
                if (!string.IsNullOrEmpty(eventName))
                {
                    this.Call(eventName, packet, args);
                }
                if (!packet.IsDecoded && this.ShouldDecodePayload(str2))
                {
                    args = packet.Decode(this.Socket.Manager.Encoder);
                }
                if (!string.IsNullOrEmpty(str2))
                {
                    this.Call(str2, packet, args);
                }
            }
        }