Ejemplo n.º 1
0
        public void Send(NetworkMessage message, NetworkDestinationEnum destination)
        {
            ++this.Instance;
            BigEndianWriter bigEndianWriter = new BigEndianWriter();

            switch (destination)
            {
            case NetworkDestinationEnum.Client:
                message.Pack((IDataWriter)bigEndianWriter, 0U);
                this.Client.Send(bigEndianWriter.Data);
                break;

            case NetworkDestinationEnum.Server:
                message.Pack((IDataWriter)bigEndianWriter, this.Instance);
                this.Server.Send(bigEndianWriter.Data);
                break;
            }
        }
Ejemplo n.º 2
0
        public void Send(MessagePart part, NetworkDestinationEnum destination)
        {
            ++this.Instance;
            BigEndianWriter bigEndianWriter1 = new BigEndianWriter();
            byte            num1             = part.Data.Length <= (int)ushort.MaxValue ? (part.Data.Length <= (int)byte.MaxValue ? ((uint)part.Data.Length <= 0U ? (byte)0 : (byte)1) : (byte)2) : (byte)3;
            BigEndianWriter bigEndianWriter2 = bigEndianWriter1;
            int?            nullable1        = part.MessageId;
            int?            nullable2        = nullable1.HasValue ? new int?(nullable1.GetValueOrDefault() << 2) : new int?();
            int             num2             = (int)num1;
            int?            nullable3;

            if (!nullable2.HasValue)
            {
                nullable1 = new int?();
                nullable3 = nullable1;
            }
            else
            {
                nullable3 = new int?(nullable2.GetValueOrDefault() | num2);
            }
            nullable1 = nullable3;
            int num3 = (int)(short)nullable1.Value;

            bigEndianWriter2.WriteShort((short)num3);
            if (destination == NetworkDestinationEnum.Server)
            {
                bigEndianWriter1.WriteUInt(this.Instance);
            }
            switch (num1)
            {
            case 1:
                bigEndianWriter1.WriteByte((byte)part.Data.Length);
                break;

            case 2:
                bigEndianWriter1.WriteShort((short)part.Data.Length);
                break;

            case 3:
                bigEndianWriter1.WriteByte((byte)(part.Data.Length >> 16 & (int)byte.MaxValue));
                bigEndianWriter1.WriteShort((short)(part.Data.Length & (int)ushort.MaxValue));
                break;
            }
            bigEndianWriter1.WriteBytes(part.Data);
            if (bigEndianWriter1.Data == null)
            {
                return;
            }
            try
            {
                switch (destination)
                {
                case NetworkDestinationEnum.Client:
                    this.Client.Send(bigEndianWriter1.Data);
                    break;

                case NetworkDestinationEnum.Server:
                    this.Server.Send(bigEndianWriter1.Data);
                    break;
                }
            }
            catch
            {
            }
        }