///<summary>Processes an authentication query.</summary> ///<param name="Query">The query to process.</param> private void ProcessQuery(byte [] Query) { try { string User = Encoding.ASCII.GetString(Query, 2, Query[1]); string Pass = Encoding.ASCII.GetString(Query, Query[1] + 3, Query[Query[1] + 2]); byte [] ToSend; if (AuthList == null || AuthList.IsItemPresent(User, Pass)) { ToSend = new byte[] { 5, 0 }; Connection.BeginSend(ToSend, 0, ToSend.Length, SocketFlags.None, new AsyncCallback(this.OnOkSent), Connection); } else { ToSend = new Byte[] { 5, 1 }; Connection.BeginSend(ToSend, 0, ToSend.Length, SocketFlags.None, new AsyncCallback(this.OnUhohSent), Connection); } } catch { Callback(false); } }
///<summary>Processes an authentication query.</summary> ///<param name="Query">The query to process.</param> private async void ProcessQuery(byte[] Query) { try { string User = Encoding.ASCII.GetString(Query, 2, Query[1]); string Pass = Encoding.ASCII.GetString(Query, Query[1] + 3, Query[Query[1] + 2]); byte[] ToSend; if (AuthList == null || AuthList.IsItemPresent(User, Pass)) { ToSend = new byte[] { 5, 0 }; await Connection.SendAsync(ToSend, this.OnOkSent); } else { ToSend = new Byte[] { 5, 1 }; await Connection.SendAsync(ToSend, this.OnUhohSent); } } catch (Exception ex) { Console.WriteLine("[WARN] " + ex.Message + "\r\n" + ex.StackTrace); Callback(this.Connection, false); } }