Пример #1
0
 private void HandleServerResponse(ServerResponseEventArgs e)
 {
     this.Dispatcher.BeginInvoke(() =>
     {
         _wait.Close();
         // Sign Up Response
         var cmd = e.Tags.GetCommands().Where(c => c.TypeName == "SIGNUP").FirstOrDefault();
         if (cmd != null)
         {
             var success = cmd.GetArg <bool>(0);
             if (success)
             {
                 ScreenManager.SetScreen(new LoginScreen());
             }
             else
             {
                 SignupForm.ValidationSummary.Errors.Add(new ValidationSummaryItem(cmd.GetArg <string>(1)));
             }
         }
         else
         {
             SignupForm.ValidationSummary.Errors.Add(new ValidationSummaryItem("An error occured on the server preventing the registration from completing. The error information has been recorded and will be addressed ASAP. Please try back again soon or contact [email protected] for assistance."));
         }
     });
 }
Пример #2
0
        /// <summary>
        /// Determines the type of data from the server and handles accordingly
        /// </summary>
        /// <param name="data"></param>
        private static void HandleData(string data)
        {
            DataPrefix type   = DataPrefix.None;
            StatusCode status = StatusCode.None;
            string     error  = string.Empty;

            // If the data is prefixed with -msg
            if (data.StartsWith(DataPrefix.Message.GetDescription()))
            {
                //Rebuild message object
                //Message message = Message.BuildMessageFromTcpString(content);

                //Raise message received event
                // MessageReceivedEventArgs args = Message.BuildMessageReceivedEvent(message);
                //message.OnMessageReceived(args);
            }

            // If the data is prefixed with -reguser
            else if (data.StartsWith(DataPrefix.RegisterUser.GetDescription()))
            {
                // Trims and splits response
                string[] response = StringHelper.TrimAndSplitTcpResponse(DataPrefix.RegisterUser, data);

                type   = DataPrefix.RegisterUser;
                status = (StatusCode)Enum.Parse(typeof(StatusCode), response[0]);
                error  = response[1];
            }

            // If the data is prefixed with -login
            else if (data.StartsWith(DataPrefix.LoginUser.GetDescription()))
            {
                string[] response = StringHelper.TrimAndSplitTcpResponse(DataPrefix.LoginUser, data);

                type   = DataPrefix.LoginUser;
                status = (StatusCode)Enum.Parse(typeof(StatusCode), response[0]);
                error  = response[1];
            }

            if (type != DataPrefix.None)
            {
                ServerResponseEventArgs args = new ServerResponseEventArgs
                {
                    Type   = type,
                    Status = status,
                    Error  = error
                };

                // Raise server response event
                OnServerResponse(args);
            }
        }
Пример #3
0
        /// <summary>
        /// Executed when the <see cref="UserRegistered"</see> event is fired/>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void ChatClient_ServerResponse(object sender, ServerResponseEventArgs e)
        {
            if (e.Type == DataPrefix.RegisterUser)
            {
                _registerUserResponse = new Response
                {
                    Status = e.Status,
                    Error  = e.Error
                };

                _userRegisteredDone.Set();
            }

            if (e.Type == DataPrefix.LoginUser)
            {
                _loginResponse = new Response
                {
                    Status = e.Status,
                    Error  = e.Error,
                };

                _userLoginDone.Set();
            }
        }
Пример #4
0
 void Instance_Response(ServerResponseEventArgs e)
 {
     this.Dispatcher.BeginInvoke(() => this.ProcessTags(e.Tags));
 }
Пример #5
0
 private void OnGetNpcTemplatesResponse(ServerResponseEventArgs e)
 {
     this.Dispatcher.BeginInvoke(() => this.ProcessNpcTemplates(e.Tags));
 }
Пример #6
0
 private void OnPlayCommandResponse(ServerResponseEventArgs e)
 {
     this.Dispatcher.BeginInvoke(() => this.ProcessPlayCommandResponse(e.Tags));
 }
Пример #7
0
 void _server_Response(ServerResponseEventArgs e)
 {
     this.Dispatcher.BeginInvoke(() => this.ProcessCheckNameResponse(e.Tags));
 }
Пример #8
0
 private void OnCreateCharacterResponse(ServerResponseEventArgs e)
 {
     this.Dispatcher.BeginInvoke(() => this.ProcessCreateCharacterResponse(e.Tags));
 }
Пример #9
0
 protected void ServerResponse(object sender, ServerResponseEventArgs e)
 {
     if (e.Response is GetRoomVariableResponse)
     {
         OnGetRoomVariableResponseRecieved(
             new GetRoomVariableResponseArgs
             {
                 Response = e.Response as GetRoomVariableResponse
             }
             );
     }
     else if (e.Response is LoginResponse)
     {
         OnLoginResponseReceieved(
             new LoginResponseEventArgs
             {
                 Response = e.Response as LoginResponse
             }
             );
     }
 }
Пример #10
0
 private void HandleServerResponse(ServerResponseEventArgs e)
 {
     this.Dispatcher.BeginInvoke(() => this.ProcessTags(e.Tags));
 }
Пример #11
0
 /// <summary>
 /// Raises UserRegistered event
 /// </summary>
 private static void OnServerResponse(ServerResponseEventArgs e)
 {
     ServerResponse?.Invoke(null, e);
 }