Difference between revisions of "MWClient execution logic"

From MMNet Wiki
Jump to navigation Jump to search
 
Line 1: Line 1:
'''Under construction'''
 
 
1) Main method sets up logs using static methods of CampaignData which points to MWLogger ( Should we switch to a logger like log4j? )
 
1) Main method sets up logs using static methods of CampaignData which points to MWLogger ( Should we switch to a logger like log4j? )
  
Line 21: Line 20:
 
9) MWClient creates a new CConnector, passing itself as the argument (since it implements IClient ) and sets the splash window.  
 
9) MWClient creates a new CConnector, passing itself as the argument (since it implements IClient ) and sets the splash window.  
  
10) If not a ded the client creates the gui etc. as follows -
+
10) If not a ded the client retrieves settings and sets data as follows -
  
 
   Create a new CCampaign which in turn holds CPlayer and a reference to MWClient
 
   Create a new CCampaign which in turn holds CPlayer and a reference to MWClient
Line 38: Line 37:
 
   create datafetcher, grab the ops
 
   create datafetcher, grab the ops
 
   delete mmconf/gameoptions.xml if it exists
 
   delete mmconf/gameoptions.xml if it exists
 +
 +
11) Once past this step both deds and players load the camaignData by calling getData() and timestamping before and after data retrieval.The datafetcher updates the last updated stamp and serialises itself
 +
 +
12) At this point deds have the username prepended with [Dedicated]
 +
 +
13) Options for dedrestarts, savedgamemaxdays, dedowners, port, ignore lists and keywords are read in at this point. The autosave purging thread is started.
 +
 +
14) The splash is set to "connecting" and the chatserver ip and port are set.
 +
 +
15) Non-dedicated clients now start loading up the gui as follows
 +
  Create a new CMainFrame passing in the MWClient as the parameter and set the logout image
 +
  Sets the window dimensions and components using either pack() or validate() depending on whether packframe is true. It also sets various gui items like size, location, state
 +
  Mute sound if set
 +
  update attack menu
 +
  set browser to allow urls to be opened in system browser
 +
  connect to chat server
 +
  set splash to "constructing gui"
 +
  set main frame to visible
 +
  get rid of the splash
 +
  refresh the status, playerpanel, bmpanel and hqpanel
 +
  Send client version and username to the chat server
 +
  Send /getsavedmail to the chat server
 +
  Start the repair thread ( for repairing mechs )
 +
 +
If it's a ded then instead it
 +
  Tries to connect to the server up to 20 times with a 90 second sleep time
 +
 +
16)Set up the timeout thread

Latest revision as of 04:14, 7 May 2016

1) Main method sets up logs using static methods of CampaignData which points to MWLogger ( Should we switch to a logger like log4j? )

2) Stdout and StdErr are set to /logs/megameklog.txt since megamek uses stdout and stderr ( duplicated code in MWDedHost, again should we use log4j? )

3) Args are parsed, ded is set to true if -dedicated is set, enable or disable splash is read.

4) New CConfig is created by reading

 data/mwconfig.txt or data/mwconfig.txt.bak
 serverdata.dat if present
 images including camo if not a dedicated server

5 )Splash screen is enabled or disabled and data/mechfiles/units.cache is deleted if it exists

6) The created CConfig is passed as the argument for a new MWClient

7) The MWClient either calls the MekWarsDed.jar if it's a dedicated instance or sets the look and feel if not.

8) MWClient stores a reference to the java runtime bean at rt

9) MWClient creates a new CConnector, passing itself as the argument (since it implements IClient ) and sets the splash window.

10) If not a ded the client retrieves settings and sets data as follows -

 Create a new CCampaign which in turn holds CPlayer and a reference to MWClient
 Grab the player reference from the CCampaign
 Initialise and set the protocal commands (comm, ping, pong and acksignon )
 Initialise and set gui commands ( Ping and Mail )
 Set the "loading data" status on the splash screen
 Show sign on dialog if autoconnect is false or if serverip, name or password are empty
 Create a datafetcher on specified port 
 Check for data/servers/<serverip>.<serverport>/dataLastUpdated.dat. Set the cache to use this directory
 Load the ops list
 set up ops

If it is a ded then it does the following

 create protocol commands
 create datafetcher, grab the ops
 delete mmconf/gameoptions.xml if it exists

11) Once past this step both deds and players load the camaignData by calling getData() and timestamping before and after data retrieval.The datafetcher updates the last updated stamp and serialises itself

12) At this point deds have the username prepended with [Dedicated]

13) Options for dedrestarts, savedgamemaxdays, dedowners, port, ignore lists and keywords are read in at this point. The autosave purging thread is started.

14) The splash is set to "connecting" and the chatserver ip and port are set.

15) Non-dedicated clients now start loading up the gui as follows

 Create a new CMainFrame passing in the MWClient as the parameter and set the logout image
 Sets the window dimensions and components using either pack() or validate() depending on whether packframe is true. It also sets various gui items like size, location, state
 Mute sound if set
 update attack menu
 set browser to allow urls to be opened in system browser 
 connect to chat server
 set splash to "constructing gui"
 set main frame to visible
 get rid of the splash
 refresh the status, playerpanel, bmpanel and hqpanel
 Send client version and username to the chat server
 Send /getsavedmail to the chat server
 Start the repair thread ( for repairing mechs )

If it's a ded then instead it

 Tries to connect to the server up to 20 times with a 90 second sleep time

16)Set up the timeout thread