diff options
| author | Paul Buetow <paul@buetow.org> | 2008-05-27 20:13:54 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-05-27 20:13:54 +0000 |
| commit | 23055ca47090021dbf84d05d5e14c8990479bfe1 (patch) | |
| tree | 36edcf38df1569abb3f81f92cf6b6acc1689b714 /sources/protocols/VSAbstractProtocol.java | |
| parent | fae58d2173039e70ad94075d49c0c500e935e454 (diff) | |
onServerStart vs onClientStart works.
Diffstat (limited to 'sources/protocols/VSAbstractProtocol.java')
| -rw-r--r-- | sources/protocols/VSAbstractProtocol.java | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/sources/protocols/VSAbstractProtocol.java b/sources/protocols/VSAbstractProtocol.java index 299d23d..461fe01 100644 --- a/sources/protocols/VSAbstractProtocol.java +++ b/sources/protocols/VSAbstractProtocol.java @@ -15,6 +15,11 @@ import core.*; */ abstract public class VSAbstractProtocol extends VSAbstractEvent { private static final long serialVersionUID = 1L; + protected static final boolean HAS_ON_SERVER_START = true; + protected static final boolean HAS_ON_CLIENT_START = false; + + /** True, if onServerStart is used, false if onClientStart is used */ + private boolean hasOnServerStart; /** The protocol object is a server. */ private boolean isServer; @@ -31,7 +36,8 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent { /** The protocol's client schedules */ private ArrayList<VSTask> clientSchedules = new ArrayList<VSTask>(); - public VSAbstractProtocol() { + public VSAbstractProtocol(boolean hasOnServerStart) { + this.hasOnServerStart = hasOnServerStart; } /** @@ -64,9 +70,16 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent { * @see events.VSAbstractEvent#onStart() */ public final void onStart() { - if (isClient) { - currentContextIsServer(false); - onClientStart(); + if (hasOnServerStart) { + if (isServer) { + currentContextIsServer(true); + onServerStart(); + } + } else { + if (isClient) { + currentContextIsServer(false); + onClientStart(); + } } } @@ -136,6 +149,15 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent { } /** + * Checks how the protocol will start + * + * @return true, if this protocol uses onServerStart instead of onClientStart + */ + public final boolean hasOnServerStart() { + return hasOnServerStart; + } + + /** * Sets if is server. * * @param isServer the is server @@ -226,7 +248,7 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent { /** * On client start. */ - abstract public void onClientStart(); + public void onClientStart() { }; /** * On client reset. @@ -251,6 +273,11 @@ abstract public class VSAbstractProtocol extends VSAbstractEvent { abstract public void onServerInit(); /** + * On server start. + */ + public void onServerStart() { }; + + /** * On server reset. */ abstract public void onServerReset(); |
