PROD_MODE & DEV_MODE - Testing Flash Game States Without Losing Your Mind
When developing online multiplayer games it is common for programmers to get very comfortable running the server code locally and compiling the swf from their IDE. Everything is fine a working during development. Then when they need to publish s final version that fits in with the rest of the game, they are scrambling to make it work. Changes are also pretty good that you will want to come back to local development after publishing that version your boss need so it is key to be able to easily and quickly flip between them. The way I have solved this problem works pretty nicely. It involves having two Boolean constants in the Model class: PROD_MODE and DEV_MODE
It’s important to notice the distinction between the two!
DEV_MODE - This describes whether you are using the development server or the actual Yahoo Games servers. If DEV_MODE is false then the client swf will look for a dll for the room class in the Yahoo Game servers corresponding to your unique gameId (remember? You used the gameId when authenticating the user). If DEV_MODE is true then the swf will be looking for the development server running the C# code locally in visual studio.
PROD_MODE - Prod mode describes whether the swf is meant to be played as it’s own standalone swf or if it’s being loaded into the full game. If PROD_MODE is false then the swf is meant to be played without any of the other states. This is used for testing, initial development of a state, and the uploaded swf’s of individual states on the site. Usually you authenticate as a random guest user to get a client object. If PROD_MODE is true then the swf will wait for the state machine class to call a start function and pass in the client object from when the user authenticated on the login screen.
Implementing the constants in your code.
In your “authenticate success” callback method triggered by a successful login from Playerio.authenticate you receive a client object. To tell the object whether to use the locally development server or your code uploaded to the YGN servers you set the development server property to your local ip. In a production case you don’t set it at all.
if (_model.DEV_MODE) {
client.multiplayer.developmentServer = “127.0.0.1”;
}
The PROD_MODE variable will allow you to specify different ways of getting a Client object.
It’s important to notice the distinction between the two!
DEV_MODE - This describes whether you are using the development server or the actual Yahoo Games servers. If DEV_MODE is false then the client swf will look for a dll for the room class in the Yahoo Game servers corresponding to your unique gameId (remember? You used the gameId when authenticating the user). If DEV_MODE is true then the swf will be looking for the development server running the C# code locally in visual studio.
PROD_MODE - Prod mode describes whether the swf is meant to be played as it’s own standalone swf or if it’s being loaded into the full game. If PROD_MODE is false then the swf is meant to be played without any of the other states. This is used for testing, initial development of a state, and the uploaded swf’s of individual states on the site. Usually you authenticate as a random guest user to get a client object. If PROD_MODE is true then the swf will wait for the state machine class to call a start function and pass in the client object from when the user authenticated on the login screen.
Implementing the constants in your code.
In your “authenticate success” callback method triggered by a successful login from Playerio.authenticate you receive a client object. To tell the object whether to use the locally development server or your code uploaded to the YGN servers you set the development server property to your local ip. In a production case you don’t set it at all.
if (_model.DEV_MODE) {
client.multiplayer.developmentServer = “127.0.0.1”;
}
The PROD_MODE variable will allow you to specify different ways of getting a Client object.