Overview
The ACHCE Client application uses two main forms to manage the user interface and player lifecycle.Form1 (ACHCE) handles player initialization, database connection, and loading screen, while Form2 manages the main application window with fullscreen display.
Form1 (ACHCE)
The primary form that manages player connection, Firebase database integration, and the initial loading screen.Class Definition
Properties
Stores the player’s public IP address retrieved from the
PublicIPAddress class.Stores the randomly generated name used as the player’s unique identifier in the Firebase database.
The Firebase client instance used for database operations.
Firebase Configuration
The form initializes a Firebase connection using the following configuration:Methods
Form1_Load
Initializes the player session by creating a Firebase client, generating a random name, retrieving the player’s IP address, and adding the player to the database.Initialization Flow
- Firebase Connection: Creates a new Firebase client
- Error Handling: Displays a message if internet connection fails
- Name Generation: Creates a random identifier for the player
- IP Retrieval: Fetches the player’s public IP address
- Database Registration: Calls
PlayAcON()to add player to database
PlayAcON
Adds the player’s information to the Firebase database under thePlayerIpList collection.
Stores player data at
PlayerIpList/{randomName} with the player’s IP address.timer1_Tick
Monitors the player initialization process and transitions to Form2 when the IP address is retrieved.Transition Logic
- Condition: Waits until
IpPlayeris populated - Action: Creates and shows Form2, hides Form1, stops timer2
- Purpose: Ensures smooth transition from loading to main application
Timer2_Tick
Updates the loading screen with a visual indicator.Form1_FormClosed
Removes the player from the database when the application is closed.This cleanup method ensures that players are automatically removed from the active player list when they exit the application, preventing stale data in the database.
Timers
Monitors player initialization and triggers the transition to Form2.
Updates the loading screen visual indicator.
Form2
The main application form that displays fullscreen content after player initialization.Class Definition
Methods
Form2_Load
Configures the form to display in fullscreen mode based on the primary monitor’s resolution.Display Configuration
Sets the form size to match the primary screen resolution for fullscreen display.
Positions the form at the top-left corner of the screen (0, 0).
pictureBox2_Click
Handles the exit button click event to close the application.Application Flow
Integration Example
Here’s how all components work together:Error Handling
Firebase Connection Errors
Best Practices
- Network validation: Check internet connectivity before attempting Firebase operations
- Graceful degradation: Provide offline functionality when possible
- User feedback: Display clear error messages and loading indicators
- Resource cleanup: Always remove player data on application exit
Related Components
- Player - Data model for player information
- IP Address - Retrieves player public IP
- Random Names - Generates unique player identifiers
UI Components
Form1 (Loading Screen)
- TextoCarga: TextBox displaying loading progress indicator
- timer1: Monitors initialization completion
- timer2: Updates loading animation
Form2 (Main Window)
- pictureBox2: Exit button image control
- Fullscreen display: Auto-configured to primary monitor resolution