Created
December 14, 2020 17:35
-
-
Save Mr00Anderson/6806bd61f9609b6205c96823531e9089 to your computer and use it in GitHub Desktop.
example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package app.virtualhex.gdx.free_universe; | |
import app.virtualhex.app.App; | |
import app.virtualhex.app.AppLauncher; | |
import app.virtualhex.gdx.engine.graphics.g2d.ExtendedDynamicAtlasWrapper; | |
import app.virtualhex.gdx.engine.state.StateRefBooleanWrapper; | |
import app.virtualhex.gdx.engine.state.StateRefStringWrapper; | |
import app.virtualhex.gdx.engine.state.StateReference; | |
import app.virtualhex.network.CachedEventLoopGroup; | |
import app.virtualhex.network.ClientPorts; | |
import com.badlogic.gdx.files.FileHandle; | |
import com.badlogic.gdx.utils.Disposable; | |
import java.util.concurrent.Executors; | |
import java.util.concurrent.ScheduledExecutorService; | |
public class FuReferences implements Disposable { | |
private static final Object OBJECT = new Object(); | |
public CachedEventLoopGroup cachedEventLoopGroup = new CachedEventLoopGroup(2); | |
public ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); | |
public String loginHost = "login.virtual-hex.com"; | |
public String charsHost = "chars.free-universe.com"; | |
public String worldsHost = "worlds.free-universe.com"; | |
public ClientPorts clientPorts = new ClientPorts(); | |
public ExtendedDynamicAtlasWrapper dynamicAtlasWrapper; | |
public StateRefBooleanWrapper rememberEmail; | |
public StateRefStringWrapper email; | |
public StateRefStringWrapper sessionToken; | |
public final Accounting accounting; | |
public FuReferences(AppLauncher<App<StateReference, FileHandle>> appLauncher, boolean clientConnectLocalHost){ | |
if(clientConnectLocalHost){ | |
loginHost = "localhost"; | |
charsHost = "localhost"; | |
worldsHost = "localhost"; | |
} | |
// TOKDO Sizing | |
dynamicAtlasWrapper = new ExtendedDynamicAtlasWrapper(2048,2048); | |
StateReference stateRef = appLauncher.getEngineApp().getState(); | |
this.rememberEmail = new StateRefBooleanWrapper("rememberSession", true, stateRef); | |
this.email = new StateRefStringWrapper("email","", stateRef); | |
this.sessionToken = new StateRefStringWrapper("token", "", stateRef); | |
this.accounting = new Accounting((FuApp) appLauncher.getEngineApp(), this); | |
} | |
// Double connect | |
public Accounting getAccounting(){ | |
return accounting; | |
} | |
@Override | |
public void dispose(){ | |
accounting.dispose(); | |
scheduledExecutorService.shutdownNow(); | |
cachedEventLoopGroup.shutdownGracefully(); | |
if(!rememberEmail.get()){ | |
email.set(""); | |
sessionToken.set(""); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment