/// <summary> /// Reads a byte corresponding to a <typeparamref name="TEnum" /> value decorated with <see cref="PacketValueAttribute"/>. /// </summary> /// <typeparam name="TEnum">The target <see langword="enum" /> type.</typeparam> /// <param name="reader">The reader to use.</param> /// <inheritdoc cref="PacketReader.ReadByte()" select="exception[@cref='PacketReadingException']" /> /// <returns>the corresponding <typeparamref name="TEnum" /> value.</returns> public static TEnum ReadByte <TEnum>(this IUnsafePacketReader reader) where TEnum : struct { Guard.NotNull(() => reader, reader); return(reader.ReadByte().ToEnumValue <TEnum>()); }
private void HandlePinValidation(IUnsafePacketReader reader) { // TODO: Configuring the server to not require PINs. var action = reader.ReadByte <PinRequestType>(); reader.Skip(5); switch (action) { case PinRequestType.PinNotSet: State = AuthClientState.AskPin; ServerSession.WritePacket(SetPinResponse()); break; case PinRequestType.CheckPin: if (CheckPin(reader)) { State = AuthClientState.LoggedIn; ServerSession.WritePacket(PinAcceptedResponse()); } else { ServerSession.WritePacket(InvalidPinResponse()); } break; case PinRequestType.AssignPin: if (CheckPin(reader)) { State = AuthClientState.LoggedIn; ServerSession.WritePacket(SetPinResponse()); } else { ServerSession.WritePacket(InvalidPinResponse()); } break; } }
private void HandlePinValidation(IUnsafePacketReader reader) { // TODO: Configuring the server to not require PINs. var action = reader.ReadByte<PinRequestType>(); reader.Skip(5); switch (action) { case PinRequestType.PinNotSet: this.State = AuthClientState.AskPin; this.ServerSession.WritePacket(this.SetPinResponse()); break; case PinRequestType.CheckPin: if (this.CheckPin(reader)) { this.State = AuthClientState.LoggedIn; this.ServerSession.WritePacket(this.PinAcceptedResponse()); } else { this.ServerSession.WritePacket(this.InvalidPinResponse()); } break; case PinRequestType.AssignPin: if (this.CheckPin(reader)) { this.State = AuthClientState.LoggedIn; this.ServerSession.WritePacket(this.SetPinResponse()); } else { this.ServerSession.WritePacket(this.InvalidPinResponse()); } break; } }