本文整理汇总了C#中Lidgren.Network.NetIncomingMessage.ReadByte方法的典型用法代码示例。如果您正苦于以下问题:C# NetIncomingMessage.ReadByte方法的具体用法?C# NetIncomingMessage.ReadByte怎么用?C# NetIncomingMessage.ReadByte使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetIncomingMessage
的用法示例。
在下文中一共展示了NetIncomingMessage.ReadByte方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decode
public override void Decode(NetIncomingMessage msg)
{
findSixes = msg.ReadBoolean();
nPosition = new HashSet<int>();
for (int i = msg.ReadByte(); i > 0; i--)
nPosition.Add(msg.ReadByte());
}
示例2: readData
public void readData(NetIncomingMessage msg)
{
while (msg.PositionInBytes < msg.LengthBytes)
{
Console.WriteLine("Data in buffer : " + (msg.LengthBytes - msg.PositionInBytes));
PacketTypes pa = (PacketTypes)msg.ReadByte();
Console.WriteLine(pa);
switch (pa)
{
case PacketTypes.ClientInput:
InputObject input = new InputObject();
InputParser.readBytes(msg, ref input);
Player p = Players[msg.SenderConnection.RemoteUniqueIdentifier];
p.Input = input;
break;
default:
Console.WriteLine("overflow : " + msg.ReadByte());
break;
}
}
}
示例3: Decode
public void Decode(NetIncomingMessage im)
{
this.Username = im.ReadString();
this.ID = im.ReadByte();
this.Me = im.ReadBoolean();
this.Color = new Color(im.ReadByte(), im.ReadByte(), im.ReadByte());
}
示例4: HandleMessage
private static void HandleMessage(NetIncomingMessage inc, NetServer server)
{
switch (inc.MessageType)
{
case NetIncomingMessageType.ConnectionApproval: //If ConnectionApproval request
if (inc.ReadByte() == (byte) PacketTypes.Headers.Login)
{
string username = inc.ReadString();
Console.WriteLine("New Login Request from: {0}", username);
if (username.Length > 1 & Players.Values.All(c => c.Name != username) &
!_badwordList.Contains(username, StringComparer.OrdinalIgnoreCase))
{
inc.SenderConnection.Approve();
NetOutgoingMessage connectedMessage = server.CreateMessage();
Thread.Sleep(500);
Console.WriteLine("Sending a ack to {0}", username);
connectedMessage.Write((byte) PacketTypes.Headers.LoggedIn);
connectedMessage.Write(true);
server.SendMessage(connectedMessage, inc.SenderConnection, NetDeliveryMethod.ReliableOrdered);
}
else
{
inc.SenderConnection.Deny("Bad Username");
}
}
break;
case NetIncomingMessageType.Data:
byte packetheader = inc.ReadByte();
HandleProtocol(inc, packetheader, server);
break;
case NetIncomingMessageType.StatusChanged:
Console.WriteLine(inc.SenderConnection + " status changed. " + inc.SenderConnection.Status);
if (inc.SenderConnection.Status == NetConnectionStatus.Disconnected)
{
Console.WriteLine("Player: {0} has disconnected",
Players[inc.SenderConnection.RemoteUniqueIdentifier].Name);
Players.Remove(inc.SenderConnection.RemoteUniqueIdentifier);
}
break;
case NetIncomingMessageType.DiscoveryRequest:
NetOutgoingMessage discovermsg = server.CreateMessage();
discovermsg.Write("Hey I just met you, I'm a server, so address me maybe");
Console.WriteLine(@"Auto Discovery Request");
server.SendDiscoveryResponse(discovermsg, inc.SenderEndPoint);
break;
case NetIncomingMessageType.DebugMessage:
case NetIncomingMessageType.ErrorMessage:
case NetIncomingMessageType.WarningMessage:
case NetIncomingMessageType.VerboseDebugMessage:
Console.WriteLine(@"---Debug---");
Console.WriteLine(inc.ReadString());
Console.WriteLine(@"---End---");
break;
}
}
示例5: Decode
public void Decode(NetIncomingMessage im)
{
this.BlockID = im.ReadByte();
this.X = im.ReadInt16();
this.Y = im.ReadInt16();
this.Z = im.ReadByte();
}
示例6: readBytes
public static void readBytes(NetIncomingMessage data, ref InputObject io)
{
data.ReadByte();
Console.WriteLine(io.HorizontalAxis = data.ReadFloat());
Console.WriteLine(io.VerticalAxis = data.ReadFloat());
Console.WriteLine(io.AmingAngle = data.ReadFloat());
Console.WriteLine(io.Buttons = data.ReadByte());
}
示例7: Read
public static PlayerInformation Read(NetIncomingMessage packet)
{
Byte slot = packet.ReadByte();
TeamType team = (TeamType)packet.ReadByte();
String callsign = packet.ReadString();
String tag = packet.ReadString();
return new PlayerInformation(slot, callsign, tag, team);
}
示例8: 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);
}
示例9: OnAdvancedNetworkMessage
public override void OnAdvancedNetworkMessage(NetIncomingMessage msg)
{
if (msg.ReadByte() == 0)
{
this.lxLoot = new List<PreSeededLoot>();
byte byCount = msg.ReadByte();
for (int i = 0; i < (int)byCount; i++)
{
this.lxLoot.Add(new PreSeededLoot(msg.ReadUInt16(), (ItemCodex.ItemTypes)msg.ReadInt32(), new Vector2(msg.ReadFloat(), msg.ReadFloat())));
}
}
}
示例10: Decode
public void Decode(NetIncomingMessage im)
{
this.ServerName = im.ReadString();
this.Description = im.ReadString();
this.Intro = im.ReadString();
this.Online = im.ReadByte();
int roomsLength = im.ReadByte();
for (int i = 0; i < roomsLength; i++)
{
Rooms.Add(new LobbySaveData(im.ReadString(), im.ReadInt16(), im.ReadString(), im.ReadByte(), im.ReadInt16(), im.ReadDouble()));
}
}
示例11: ReadFromMessage
public static NetObject ReadFromMessage(NetIncomingMessage message)
{
var type = (NetObjectType)message.ReadByte();
var instance = (NetObject)Activator.CreateInstance(netObjectTypes[type]);
instance.Read(message);
return instance;
}
示例12: Data
private void Data(NetIncomingMessage inc)
{
var packetType = (PacketType) inc.ReadByte();
var gameRoom = GetGameRoomById(inc.ReadString());
var command = PacketFactory.GetCommand(packetType);
command.Run(_managerLogger, this,inc, null, gameRoom);
}
示例13: HandleData
/// <summary>
///
/// </summary>
/// <param name="incomingMsg"></param>
public void HandleData(NetIncomingMessage incomingMsg)
{
MessageType messageType = (MessageType)incomingMsg.ReadByte();
switch (messageType)
{
case MessageType.MsgState:
SendState();
break;
case MessageType.MsgPlayerClientUpdate:
BroadcastUpdate(incomingMsg);
break;
case MessageType.MsgDeath:
Die(incomingMsg);
break;
case MessageType.MsgBeginShot:
Shoot(incomingMsg);
break;
case MessageType.MsgEndShot:
EndShot(incomingMsg);
break;
default:
break;
}
}
示例14: ReadArgument
static object ReadArgument(NetIncomingMessage msg, Type type)
{
if (type == typeof(int))
{
return msg.ReadInt32();
}
else if (type == typeof(byte))
{
return msg.ReadByte();
}
else if (type == typeof(float))
{
return msg.ReadFloat();
}
else if (type == typeof(Vector3))
{
return NetworkUtils.ReadVector3(msg);
}
else if (type == typeof(Quaternion))
{
return NetworkUtils.ReadQuaternion(msg);
}
else if (type == typeof(string))
{
return msg.ReadString();
}
else
{
throw new Exception("Unsupported argument type " + type);
}
}
示例15: LidgrenStatusChangeMessageContext
public LidgrenStatusChangeMessageContext(NetIncomingMessage incomingMessage)
: base(incomingMessage)
{
LidgrenStatus = (NetConnectionStatus)incomingMessage.ReadByte();
//Generate a Lidgren status message for dispatching
GeneratedStatusMessage = new LidgrenStatusMessage(LidgrenStatus);
}