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.")); } }); }
/// <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); } }
/// <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(); } }
void Instance_Response(ServerResponseEventArgs e) { this.Dispatcher.BeginInvoke(() => this.ProcessTags(e.Tags)); }
private void OnGetNpcTemplatesResponse(ServerResponseEventArgs e) { this.Dispatcher.BeginInvoke(() => this.ProcessNpcTemplates(e.Tags)); }
private void OnPlayCommandResponse(ServerResponseEventArgs e) { this.Dispatcher.BeginInvoke(() => this.ProcessPlayCommandResponse(e.Tags)); }
void _server_Response(ServerResponseEventArgs e) { this.Dispatcher.BeginInvoke(() => this.ProcessCheckNameResponse(e.Tags)); }
private void OnCreateCharacterResponse(ServerResponseEventArgs e) { this.Dispatcher.BeginInvoke(() => this.ProcessCreateCharacterResponse(e.Tags)); }
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 } ); } }
private void HandleServerResponse(ServerResponseEventArgs e) { this.Dispatcher.BeginInvoke(() => this.ProcessTags(e.Tags)); }
/// <summary> /// Raises UserRegistered event /// </summary> private static void OnServerResponse(ServerResponseEventArgs e) { ServerResponse?.Invoke(null, e); }