protected void f_play_anon(enum_theme a_enum_theme) { // Log that the user has clicked the 'Play now' button. HedgeEmLogEvent my_log_event = new HedgeEmLogEvent(); my_log_event.p_method_name = System.Reflection.MethodBase.GetCurrentMethod().ToString(); my_log_event.p_table_id = p_session_personal_table_id; my_log_event.p_server_id = p_session_server_id; my_log_event.p_message = String.Format("User [{0}] click 'Play Now", p_session_username); log.Info(my_log_event.ToString()); // This fucntion should not be able to be played if the player as not logged in, so test if they have // a 'HedgeEm Session' has been established, If not exit this fucntion. /*if (!p_valid_session_exists) { my_log_event.p_message = String.Format("User informed the session is invalide."); log.Debug(my_log_event.ToString()); //ScriptManager.RegisterStartupScript(Page, GetType(), "Alert Message", "alert('You must be logged in to Play this game.');", true); ScriptManager.RegisterStartupScript(Page, GetType(), "Alert Message", "document.getElementById('alertmessage').style.display = 'block';", true); return; }*/ // xxx Consider uncommenting the following after aslo considering consequence (if you do this when user clicks leave table // they will leave there personal table which you may not want currently as the code currently (Dec 2014) assumes you are sitting at // personal table all the time. HedgeEmPlayer my_hedgeem_player; //my_hedgeem_player = f_get_free_anonymous_player(); DC_hedgeem_game_state my_game_state = f_sit_at_anonymous_table(a_enum_theme); //f_login_anonymously(1201); if (my_game_state.p_error_message != null) { if (my_game_state.p_error_message != "") { throw new Exception(my_game_state.p_error_message); } } Session["p_session_username"] = my_game_state._seats[0].p_player_name; Session["p_session_personal_table_id"] = my_game_state.p_table_id; Session["p_session_current_table_id"] = my_game_state.p_table_id; Session["p_session_player_id"] = my_game_state._seats[0].p_player_id; Session["theme"] = a_enum_theme.ToString(); Session["role"] = "BASIC_USER"; f_goto_table(my_game_state.p_table_id); // If code reaches here we asssume Table ID and PlayerID is known so sit the person at this table }
private DC_hedgeem_game_state f_sit_at_anonymous_table(enum_theme a_enum_theme ) { HedgeEmLogEvent my_log_event = new HedgeEmLogEvent(); DC_hedgeem_game_state my_game_state = new DC_hedgeem_game_state(); my_log_event.p_method_name = System.Reflection.MethodBase.GetCurrentMethod().ToString(); my_log_event.p_message = "f_sit_at_anonymous_table"; log.Debug(_xxx_log_event.ToString()); string my_endpoint = "Not Set"; try { try { // Creates (registers) a new user (HedgeEmPlayer) in the HedgeEm Server. // Note this also creates a Personal Table for them (which the HedgeEmTable is returned in the Player object 'p_personal_table_id enum_authentication_method my_authentication_method = enum_authentication_method.FACEBOOK; my_endpoint = String.Format("{0}/ws_sit_at_anonymous_table/{1},{2},{3},{4}/", p_current_json_webservice_url_base, "anon_session_id_123", 83, a_enum_theme.ToString(), "FASTPLAY_FLOP"); my_game_state = (DC_hedgeem_game_state)f_get_object_from_json_call_to_server(my_endpoint, typeof(DC_hedgeem_game_state)); if (my_game_state.p_error_message != null) { if (my_game_state.p_error_message != "") { string my_error_msg = string.Format("Failed trying call 'sit anonymously' to server, Error returned [{0}], Endpoint targeted [{1}]",my_game_state.p_error_message,my_endpoint); throw new Exception(my_error_msg); } } // If we got here we assume Player was created successfully so store Player ID and continue //p_session_player_id = my_game_state.p_player_id; // login to the game /*Session["p_session_username"] = txt_username.Text; Session["password"] = txt_password.Text; Session["display_name"] = txt_full_name.Text; Session["p_session_personal_table_id"] = my_game_state.p_personal_table_id; Session["p_session_username"] = my_game_state.p_username; Session["p_session_password"] = txt_password.Text; Session["p_session_display_name"] = my_game_state.p_display_name; ScriptManager.RegisterStartupScript(Page, GetType(), "OnLoad", "alert('Thank you for registering,your facebook account with HedgeEm. A confirmation mail is sent to your email Id '); if(alert){ window.location='frm_facebook_canvas.aspx';}", true); */ //Page.RegisterStartupScript("OnLoad", "<script>alert('Thank you for registering, you are now logged in an can start to play HedgeEm'); if(alert){ window.location='frm_facebook_canvas.aspx';}</script>"); } catch (Exception ex) { string my_error_msg_summary = String.Format("Fatal error trying to sit at table anonymously"); string my_error_msg_detail = String.Format("Error in {0} Reason [{1}]", my_log_event.p_method_name, ex.Message.ToString()); my_log_event.p_message = my_error_msg_detail; log.Error(my_log_event.ToString()); HedgeemerrorPopup my_popup_messageError = new HedgeemerrorPopup(); my_popup_messageError.p_user_message_str = my_error_msg_summary; my_popup_messageError.p_detailed_message_str = my_error_msg_detail; my_popup_messageError.p_is_visible = true; Place_Holder_Popup_Message.Controls.Add(my_popup_messageError); my_popup_messageError.Dispose(); //newuser.Visible = false; } } catch (Exception ex) { string my_error_popup = "Error in f_get_free_anonymous_player suald - " + ex.Message.ToString(); // ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", my_error_popup, true); log.Error("Error in f_get_free_anonymous_player xxxaawe", new Exception(ex.Message)); HedgeemerrorPopup my_popup_message = new HedgeemerrorPopup(); my_popup_message.p_detailed_message_str = ""; my_popup_message.p_detailed_message_str = my_error_popup; my_popup_message.p_is_visible = true; //newuser.Visible = false; Place_Holder_Popup_Message.Controls.Add(my_popup_message); my_popup_message.Dispose(); } return my_game_state; }