Esempio n. 1
0
        private void EnqueueOutput(RoutedMessage data)
        {
            if (this._isStopping)
            {
                this._outputQueue.CompleteAdding();
                return;
            }

            this._outputQueue.Add(data);
        }
Esempio n. 2
0
        public unsafe void Output(AnalyzedPacket analyzedPacket)
        {
            // for default filter set we use, every single filter is mutually exclusive.
            if (analyzedPacket.Message.Length < HeaderLength)
            {
                return;
            }

            NetworkMessageHeader header;

            fixed(byte *p = &analyzedPacket.Message[0])
            {
                header = *(NetworkMessageHeader *)p;
            }

            int opcode = header.OpCode;

            if (analyzedPacket.RouteMark.GetCatalog() == MessageAttribute.CatalogLobby)
            {
                opcode |= OPMASK_LOBBY;
            }

            if (analyzedPacket.RouteMark.GetDirection() == MessageAttribute.DirectionSend)
            {
                opcode = -opcode;
            }

            if (!_consumerTypes.TryGetValue(opcode, out var consumer))
            {
                return;
            }

            if (!_listeners.TryGetValue(opcode, out var listener) || listener == null)
            {
                return;
            }

            var rm = new RoutedMessage(header, HeaderLength, analyzedPacket.Message, consumer, listener);

            EnqueueOutput(rm);
        }