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


C# PacketReader.ReadUTFString方法代码示例

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


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

示例1: 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

示例2: Parse

        public IEnumerable<RuleInfo> Parse(byte[] data)
        {
            var rules = new List<RuleInfo>();
            var reader = new PacketReader(data);

            var header = reader.ReadByte();
            var numberOfRules = reader.ReadShort();

            for (short i = 1; i <= numberOfRules; i++)
            {
                if (!reader.IsEnd)
                {
                    var rule = new RuleInfo();
                    rule.Index = i;
                    rule.Name = reader.ReadUTFString();
                    rule.Value = reader.ReadUTFString();
                    rules.Add(rule);
                }
            }

            return rules;
        }
开发者ID:AlexSbyshko,项目名称:Barsik,代码行数:22,代码来源:RulesParser.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: Parse

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

            var header = reader.ReadByte();
            var headerChar = Convert.ToChar(header);
            var protocol = reader.ReadByte();
            var name = reader.ReadUTFString();
            var map = reader.ReadUTFString();
            var folder = reader.ReadUTFString();
            var game = reader.ReadUTFString();
            var appId = reader.ReadShort();
            var players = reader.ReadByte();
            var maxPlayers = reader.ReadByte();
            var bots = reader.ReadByte();
            var type = reader.ReadByte();
            var environment = reader.ReadByte();
            var visibility = reader.ReadByte();
            var isSecured = reader.ReadByte();
            var version = reader.ReadUTFString();

            server.Name = name;
            server.Map = map;
            server.Players = players;
            server.MaxPlayers = maxPlayers;
            server.Bots = bots;
            server.Game = game;
            server.AppId = appId;
            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;
                case 'm':
                case 'o':
                    server.Environment = ServerEnvironment.Mac;
                    break;
            }

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

            if (!reader.IsEnd)
            {
                var extraDataFlag = reader.ReadByte();
                if ((extraDataFlag & 0x80) > 0)
                {
                    server.Port = reader.ReadShort();
                }
                if ((extraDataFlag & 0x10) > 0)
                {
                    server.SteamId = reader.ReadLongLong();
                }
                if ((extraDataFlag & 0x40) > 0)
                {
                    server.SourceTVPort = reader.ReadShort();
                    server.SourceTVName = reader.ReadUTFString();
                }
                if ((extraDataFlag & 0x20) > 0)
                {
                    server.Tags = reader.ReadUTFString();
                }
                if ((extraDataFlag & 0x01) > 0)
                {
                    server.GameId = reader.ReadLongLong();
                }
            }

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


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