Advertisement
Guest User

Untitled

a guest
Dec 8th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 KB | None | 0 0
  1. using ShatteredRelic.Networking;
  2. using UnityEngine;
  3.  
  4. public class RequestLogin : IMessageBuilder
  5. {
  6.  
  7.     /// <summary>
  8.     /// Represents the Username Request
  9.     /// </summary>
  10.     private string Username;
  11.  
  12.     /// <summary>
  13.     /// Represents the Password Request
  14.     /// </summary>
  15.     private string Password;
  16.  
  17.     /// <summary>
  18.     /// Represents if Logging into the World
  19.     /// </summary>
  20.     private bool World;
  21.  
  22.     /// <summary>
  23.     /// Represents the Character Name
  24.     /// </summary>
  25.     private string CharacterName;
  26.  
  27.     /// <summary>
  28.     /// Creates a new Request Default  Login Packet
  29.     /// </summary>
  30.     /// <param name="Username"></param>
  31.     /// <param name="Password"></param>
  32.     public RequestLogin(string Username, string Password)
  33.     {
  34.         this.Username = Username;
  35.         this.Password = Password;
  36.     }
  37.    
  38.     /// <summary>
  39.     /// Creates a new Request Login Packet
  40.     /// </summary>
  41.     /// <param name="Username"></param>
  42.     /// <param name="Password"></param>
  43.     /// <param name="CharacterName"></param>
  44.     public RequestLogin(string Username, string Password, string CharacterName)
  45.     {
  46.         this.Username = Username;
  47.         this.Password = Password;
  48.         this.CharacterName = CharacterName;
  49.         World = true;
  50.     }
  51.    
  52.     /// <summary>
  53.     /// Builds a Login Request to send to the Server
  54.     /// </summary>
  55.     /// <returns></returns>
  56.     public OutputByteBuffer Build() {
  57.         OutputByteBuffer buffer = new OutputByteBuffer((int) ClientMessages.LOGIN_REQUEST);
  58.         buffer.writeByte(1);
  59.         buffer.writeInt(116);
  60.         buffer.writeShort(10267);
  61.         buffer.writeString(Username);
  62.         buffer.writeString(Password);
  63.         buffer.writeByte(World ? 1 : 0);
  64.         if (World)
  65.             buffer.writeString(CharacterName);
  66.         Debug.Log("Sending Login Request: " + Username + ", " + Password);
  67.         return buffer;
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement