protected override void Decode(ByteList bytes) { Log.Debug("Decode an GameDef"); if (bytes == null || !bytes.IsMore) { return; } GameId = bytes.GetShort(); Log.DebugFormat("Decoded GameId = {0}", GameId); if (!bytes.IsMore) { return; } Hint = bytes.GetString(); Log.DebugFormat("Decoded Hint = {0}", Hint); if (!bytes.IsMore) { return; } Definition = bytes.GetString(); Log.DebugFormat("Decoded Definition = {0}", Definition); }
protected override void Decode(ByteList bytes) { Log.Debug("Decode a NewGameMessage"); if (bytes == null || !bytes.IsMore) { return; } Log.Debug("Try to get the A#"); if (bytes.PeekShort() < 0 && bytes.PeekShort() > 24) { Log.Warn($"The length of the encoded A#, {bytes.PeekShort()}, is probably not correct. Check how you are encoding the string's length"); } ANumber = bytes.GetString(); Log.Debug($"Decoded A# = {ANumber}"); if (string.IsNullOrWhiteSpace(ANumber) || !ANumber.StartsWith("A")) { Log.Warn($"The ANumber doesn't start with an A, and therefore may not be encoded correctly"); } if (!bytes.IsMore) { return; } Log.Debug("Try to get the LastName"); if (bytes.PeekShort() < 0 && bytes.PeekShort() > 48) { Log.Warn($"The length of the encoded LastName, {bytes.PeekShort()}, is probably not correct. Check how you are encoding the string's length"); } LastName = bytes.GetString(); Log.Debug($"Decoded LastName = {LastName}"); if (!bytes.IsMore) { return; } Log.Debug("Try to get the FirstName"); if (bytes.PeekShort() < 0 && bytes.PeekShort() > 48) { Log.Warn($"The length of the encoded FirstName, {bytes.PeekShort()}, is probably not correct. Check how you are encoding the string's length"); } FirstName = bytes.GetString(); Log.Debug($"Decoded FirstName = {FirstName}"); if (!bytes.IsMore) { return; } Log.Debug("Try to get the Alias"); if (bytes.PeekShort() < 0 && bytes.PeekShort() > 48) { Log.Warn($"The length of the encoded Alias, {bytes.PeekShort()}, is probably not correct. Check how you are encoding the string's length"); } Alias = bytes.GetString(); Log.Debug($"Decoded Alias = {Alias}"); }
protected override void Decode(ByteList bytes) { Log.Debug("Decode a AnswerMessage"); if (bytes == null || !bytes.IsMore) { return; } GameId = bytes.GetShort(); Log.DebugFormat("Decoded GameId = {0}", GameId); if (!bytes.IsMore) { return; } Result = (bytes.GetByte() == 1); Log.DebugFormat("Decoded Result = {0}", Result); if (!bytes.IsMore) { return; } Score = bytes.GetShort(); Log.DebugFormat("Decoded Score = {0}", Score); if (!bytes.IsMore) { return; } Hint = bytes.GetString(); Log.DebugFormat("Decoded Hint = {0}", Hint); }
public void Decode(ByteList bytes) { Id = bytes.GetInt(); Alias = bytes.GetString(); GameCount = bytes.GetInt(); GuessCount = bytes.GetInt(); HintCount = bytes.GetInt(); ExitCount = bytes.GetInt(); HeartbeatCount = bytes.GetInt(); HighScore = bytes.GetInt(); LastMessage = DateTime.FromBinary(bytes.GetLong()); Log.Debug($"Decoded Player = {ToString()}"); }
/// <summary> /// This method decodes a message from a byte list /// </summary> /// <param name="bytes"></param> public override void Decode(ByteList bytes) { Int16 objType = bytes.GetInt16(); Int16 objLength = bytes.GetInt16(); bytes.SetNewReadLimit(objLength); base.Decode(bytes); ReplyType = (PossibleTypes)Convert.ToInt32(bytes.GetByte()); Status = (PossibleStatus)Convert.ToInt32(bytes.GetByte()); Note = bytes.GetString(); bytes.RestorePreviosReadLimit(); }
override public void Decode(ByteList bytes) { Int16 objType = bytes.GetInt16(); Int16 objLength = bytes.GetInt16(); bytes.SetNewReadLimit(objLength); base.Decode(bytes); IntResult = bytes.GetInt32(); ObjResult = bytes.GetDistributableObject(); Message = bytes.GetString(); bytes.RestorePreviosReadLimit(); }
protected override void Decode(ByteList bytes) { Log.Debug("Decode an ErrorMessage"); if (bytes == null || !bytes.IsMore) { return; } GameId = bytes.GetShort(); Log.DebugFormat("Decoded GameId = {0}", GameId); if (!bytes.IsMore) { return; } ErrorText = bytes.GetString(); Log.DebugFormat("Decoded ErrorText = {0}", ErrorText); }
protected override void Decode(ByteList bytes) { Log.Debug("Decode an GuessMessage"); if (bytes == null || !bytes.IsMore) { return; } GameId = bytes.GetShort(); Log.DebugFormat("Decoded GameId = {0}", GameId); if (!bytes.IsMore) { return; } Log.Debug("Try to get the FirstName"); if (bytes.PeekShort() < 0 && bytes.PeekShort() > 40) { Log.WarnFormat("The length of the encoded Word, {0}, is probably not correct. Check how you are encoding the string's length", bytes.PeekShort()); } Word = bytes.GetString(); Log.DebugFormat("Decoded Word = {0}", Word); }