예제 #1
0
 public IncomingErrorMessageEventArgs(int errorCode, string message, FowaClient fowaClient)
 {
     this.Errorcode = errorCode;
     this.Message = message;
     this.FowaClient = fowaClient;
 }
예제 #2
0
 private FowaConnection()
 {
     _fowaClient = new FowaClient();
 }
예제 #3
0
 public IncomingMessageEventArgs(string message, FowaClient fowaClient)
 {
     this.Message = message;
     this.FowaClient = fowaClient;
     //this.SenderNetworkStream = senderNetworkStream;
 }
예제 #4
0
        public async Task<int> HandleIncomingLoginOrRegisterMessage(FowaClient client, string email)
        {
            bool writeToClientSuccessfull = true; // Not used yet
            bool userExists = true;
            bool dbConnectionSuccessfull = true;
            string possibleException = string.Empty;

            try
            {
                // Check if user exists
                userExists = _userFriendService.UserExists(email);
            }
            catch (Exception ex)
            {
                // Log ex
                possibleException = ex.Message;
                dbConnectionSuccessfull = false;
            }

            if (!userExists)
            {
                await Dispatcher.BeginInvoke(new Action(() => fowaServerLogTextBlock.Text += "Login failed: User not found.\n----------\n"));
                //writeToClientSuccessfull = await client.WriteToClientStreamAync(new ErrorMessage(ErrorMessageKind.LoginError, "User not found."));
            }

            if (!dbConnectionSuccessfull)
            {
                await Dispatcher.BeginInvoke(new Action(() => fowaServerLogTextBlock.Text += "DB connection failed.\n----------\n" + possibleException));
                //writeToClientSuccessfull = await client.WriteToClientStreamAync(new ErrorMessage(ErrorMessageKind.LoginError, "Fetching Friends failed."));
            }

            if (!dbConnectionSuccessfull) return 0; // DB con failed
            return userExists ? 1 : 2; // user exists = 1
            // User does not exists = 2
        }