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


C# NetIncomingMessage.ReadSByte方法代码示例

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


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

示例1: HandleEntityComponentNetworkMessage

 /// <summary>
 /// Handles an incoming entity component message
 /// </summary>
 /// <param name="message">Raw network message</param>
 /// <returns>An IncomingEntityComponentMessage object</returns>
 public IncomingEntityComponentMessage HandleEntityComponentNetworkMessage(NetIncomingMessage message)
 {
     var componentFamily = (ComponentFamily) message.ReadByte();
     var messageParams = new List<object>();
     while (message.Position < message.LengthBits)
     {
         switch ((NetworkDataType) message.ReadByte())
         {
             case NetworkDataType.d_enum:
                 messageParams.Add(message.ReadInt32());
                 break;
             case NetworkDataType.d_bool:
                 messageParams.Add(message.ReadBoolean());
                 break;
             case NetworkDataType.d_byte:
                 messageParams.Add(message.ReadByte());
                 break;
             case NetworkDataType.d_sbyte:
                 messageParams.Add(message.ReadSByte());
                 break;
             case NetworkDataType.d_ushort:
                 messageParams.Add(message.ReadUInt16());
                 break;
             case NetworkDataType.d_short:
                 messageParams.Add(message.ReadInt16());
                 break;
             case NetworkDataType.d_int:
                 messageParams.Add(message.ReadInt32());
                 break;
             case NetworkDataType.d_uint:
                 messageParams.Add(message.ReadUInt32());
                 break;
             case NetworkDataType.d_ulong:
                 messageParams.Add(message.ReadUInt64());
                 break;
             case NetworkDataType.d_long:
                 messageParams.Add(message.ReadInt64());
                 break;
             case NetworkDataType.d_float:
                 messageParams.Add(message.ReadFloat());
                 break;
             case NetworkDataType.d_double:
                 messageParams.Add(message.ReadDouble());
                 break;
             case NetworkDataType.d_string:
                 messageParams.Add(message.ReadString());
                 break;
             case NetworkDataType.d_byteArray:
                 int length = message.ReadInt32();
                 messageParams.Add(message.ReadBytes(length));
                 break;
         }
     }
     return new IncomingEntityComponentMessage(componentFamily, messageParams);
 }
开发者ID:Tri125,项目名称:space-station-14,代码行数:60,代码来源:EntityNetworkManager.cs

示例2: UnPackParams

 private List<object> UnPackParams(NetIncomingMessage message)
 {
     var messageParams = new List<object>();
     while (message.Position < message.LengthBits)
     {
         switch ((NetworkDataType) message.ReadByte())
         {
             case NetworkDataType.d_enum:
                 messageParams.Add(message.ReadInt32()); //Cast from int, because enums are ints.
                 break;
             case NetworkDataType.d_bool:
                 messageParams.Add(message.ReadBoolean());
                 break;
             case NetworkDataType.d_byte:
                 messageParams.Add(message.ReadByte());
                 break;
             case NetworkDataType.d_sbyte:
                 messageParams.Add(message.ReadSByte());
                 break;
             case NetworkDataType.d_ushort:
                 messageParams.Add(message.ReadUInt16());
                 break;
             case NetworkDataType.d_short:
                 messageParams.Add(message.ReadInt16());
                 break;
             case NetworkDataType.d_int:
                 messageParams.Add(message.ReadInt32());
                 break;
             case NetworkDataType.d_uint:
                 messageParams.Add(message.ReadUInt32());
                 break;
             case NetworkDataType.d_ulong:
                 messageParams.Add(message.ReadUInt64());
                 break;
             case NetworkDataType.d_long:
                 messageParams.Add(message.ReadInt64());
                 break;
             case NetworkDataType.d_float:
                 messageParams.Add(message.ReadFloat());
                 break;
             case NetworkDataType.d_double:
                 messageParams.Add(message.ReadDouble());
                 break;
             case NetworkDataType.d_string:
                 messageParams.Add(message.ReadString());
                 break;
             case NetworkDataType.d_byteArray:
                 int length = message.ReadInt32();
                 messageParams.Add(message.ReadBytes(length));
                 break;
         }
     }
     return messageParams;
 }
开发者ID:millpond,项目名称:space-station-14,代码行数:54,代码来源:EntityNetworkManager.cs

示例3: ReadValue

            private static Object ReadValue(NetIncomingMessage packet, TypeCode typeCode)
            {
                Object value;

                switch (typeCode)
                {
                    case TypeCode.Empty:
                        throw new NotSupportedException("Empty is not a supported type for variables");

                    case TypeCode.Object:
                        throw new NotSupportedException("Object is not a supported type for variables");

                    case TypeCode.DBNull:
                        throw new NotSupportedException("DBNull is not a supported type for variables");

                    case TypeCode.Boolean:
                        value = packet.ReadBoolean();
                        break;

                    case TypeCode.Char:
                        throw new NotSupportedException("Char is not a supported type for variables");

                    case TypeCode.SByte:
                        value = packet.ReadSByte();
                        break;

                    case TypeCode.Byte:
                        value = packet.ReadByte();
                        break;

                    case TypeCode.Int16:
                        value = packet.ReadInt16();
                        break;

                    case TypeCode.UInt16:
                        value = packet.ReadUInt16();
                        break;

                    case TypeCode.Int32:
                        value = packet.ReadInt32();
                        break;

                    case TypeCode.UInt32:
                        value = packet.ReadUInt32();
                        break;

                    case TypeCode.Int64:
                        value = packet.ReadInt64();
                        break;

                    case TypeCode.UInt64:
                        value = packet.ReadUInt64();
                        break;

                    case TypeCode.Single:
                        value = packet.ReadSingle();
                        break;

                    case TypeCode.Double:
                        value = packet.ReadDouble();
                        break;

                    case TypeCode.Decimal:
                        throw new NotSupportedException("Decimal is not a supported type for variables");

                    case TypeCode.DateTime:
                        throw new NotSupportedException("DateTime is not a supported type for variables");

                    case TypeCode.String:
                        value = packet.ReadString();
                        break;

                    default:
                        throw new NotSupportedException(String.Format("Unknown type {0} is not a supported type for variables", typeCode));
                }

                return value;
            }
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:78,代码来源:Messages.cs


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