当前位置: 首页>>代码示例>>C#>>正文


C# PacketReader.ReadLong方法代码示例

本文整理汇总了C#中PacketReader.ReadLong方法的典型用法代码示例。如果您正苦于以下问题:C# PacketReader.ReadLong方法的具体用法?C# PacketReader.ReadLong怎么用?C# PacketReader.ReadLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PacketReader的用法示例。


在下文中一共展示了PacketReader.ReadLong方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Parse

 public int Parse(byte[] data)
 {
     var reader = new PacketReader(data);
     var header = reader.ReadByte();
     var number = reader.ReadLong();
     return number;
 }
开发者ID:AlexSbyshko,项目名称:Barsik,代码行数:7,代码来源:ChallengeParser.cs

示例2: Parse

        public IEnumerable<PlayerInfo> Parse(byte[] data)
        {
            var players = new List<PlayerInfo>();

            var reader = new PacketReader(data);

            var header = reader.ReadByte();
            var chard = Convert.ToChar(header);

            var numberOfPlayers = reader.ReadByte();

            for (byte i = 1; i <= numberOfPlayers; i++)
            {
                var player = new PlayerInfo();
                if (!reader.IsEnd)
                {
                    player.Index = reader.ReadByte(); // always returns 0
                    player.Index = i;
                    player.Name = reader.ReadUTFString();
                    player.Score = reader.ReadLong();
                    player.Duration = reader.ReadFloat();
                }
                players.Add(player);
            }

            return players;
        }
开发者ID:AlexSbyshko,项目名称:Barsik,代码行数:27,代码来源:PlayersParser.cs

示例3: Parse

        public ServerInfo Parse(byte[] data)
        {
            var server = new ServerInfo();
            var reader = new PacketReader(data);

            var header = reader.ReadByte();
            var address = reader.ReadUTFString();
            var name = reader.ReadUTFString();
            var map = reader.ReadUTFString();
            var folder = reader.ReadUTFString();
            var game = reader.ReadUTFString();
            var players = reader.ReadByte();
            var maxPlayers = reader.ReadByte();
            var protocol = reader.ReadByte();
            var type = reader.ReadByte();
            var environment = reader.ReadByte();
            var visibility = reader.ReadByte();
            var mod = reader.ReadByte();
            var version = 0;
            if (mod == 1)
            {
                var link = reader.ReadUTFString();
                var downloadLink = reader.ReadUTFString();
                var nullByte = reader.ReadByte();
                version = reader.ReadLong();
                var size = reader.ReadLong();
                var mptype = reader.ReadByte();
                var dll = reader.ReadByte();
            }
            var isSecured = reader.ReadByte();
            var bots = reader.ReadByte();

            server.Name = name;
            server.Map = map;
            server.Players = players;
            server.MaxPlayers = maxPlayers;
            server.Bots = bots;
            server.Game = game;
            server.AppId = -1;
            server.Folder = folder;
            server.Protocol = protocol;

            var typeChar = Convert.ToChar(type);
            switch (typeChar)
            {
                case 'd':
                    server.Type = ServerType.Dedicated;
                    break;
                case 'l':
                    server.Type = ServerType.NonDedicated;
                    break;
                case 'p':
                    server.Type = ServerType.Proxy;
                    break;
            };

            var envirommentChar = Convert.ToChar(environment);
            switch (envirommentChar)
            {
                case 'l':
                    server.Environment = ServerEnvironment.Linux;
                    break;
                case 'w':
                    server.Environment = ServerEnvironment.Windows;
                    break;
            }

            server.Visibility = (visibility == 0) ? ServerVisibility.Public : ServerVisibility.Private;
            server.IsSecured = (isSecured == 1);
            server.Version = version.ToString();

            return server;
        }
开发者ID:AlexSbyshko,项目名称:Barsik,代码行数:73,代码来源:GoldSrcServerInfoParser.cs

示例4: Read

 public override void Read(PacketReader stream)
 {
     AgeOfWorld = stream.ReadLong();
     Time = stream.ReadLong();
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:5,代码来源:Packet.cs

示例5: ParseData

 private void ParseData(byte[] data)
 {
     var reader = new PacketReader(data);
     var header = reader.ReadLong();
     payload = reader.GetRest();
 }
开发者ID:AlexSbyshko,项目名称:Barsik,代码行数:6,代码来源:SimplePacket.cs

示例6: ParseData

        private bool ParseData(byte[] data)
        {
            var reader = new PacketReader(data);
            var header = reader.ReadLong();
            var id = reader.ReadLong();
            logger.Debug("ID: {0}", id);
            if (IsIncorrectId(id))
            {
                return false;
            }
            this.id = id;

            var numberOfPacketInfo = reader.ReadByte();
            var bits = new BitArray(new byte[] { numberOfPacketInfo });

            totalNumberOfParts = GetTotalNumberOfPackets(bits);

            logger.Debug("TOTAL PARTS: {0}", totalNumberOfParts);
            var number = GetNumberOfPacket(bits);
            logger.Debug("NUMBER: {0}", number);

            if (number == 0)
            {
                var strangeNumberInFirstPacket = reader.ReadLong();
                logger.Debug("Strange number: {0}", strangeNumberInFirstPacket);
            }

            var payloadPart = reader.GetRest();
            parts.Add(new PacketPartData { Number = number, Data = payloadPart });

            logger.Debug("END PART");

            return true;
        }
开发者ID:AlexSbyshko,项目名称:Barsik,代码行数:34,代码来源:GoldSrcMultiPacket.cs


注:本文中的PacketReader.ReadLong方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。