Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
corewars-library
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
st-praktikum16-g1
corewars-library
Commits
31199daa
Commit
31199daa
authored
Sep 30, 2016
by
matthias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
well know ports server config, added some javadoc
parent
407bdf70
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
63 additions
and
18 deletions
+63
-18
src/main/java/gone/lib/common/ClientRole.java
src/main/java/gone/lib/common/ClientRole.java
+3
-1
src/main/java/gone/lib/common/NetworkConstants.java
src/main/java/gone/lib/common/NetworkConstants.java
+3
-1
src/main/java/gone/lib/common/RcStandard.java
src/main/java/gone/lib/common/RcStandard.java
+3
-1
src/main/java/gone/lib/config/ClientConfig.java
src/main/java/gone/lib/config/ClientConfig.java
+11
-0
src/main/java/gone/lib/config/ConfigParameters.java
src/main/java/gone/lib/config/ConfigParameters.java
+2
-0
src/main/java/gone/lib/config/ConfigTypes.java
src/main/java/gone/lib/config/ConfigTypes.java
+2
-0
src/main/java/gone/lib/config/LoadConfigFile.java
src/main/java/gone/lib/config/LoadConfigFile.java
+19
-5
src/main/java/gone/lib/config/SaveConfigFile.java
src/main/java/gone/lib/config/SaveConfigFile.java
+17
-8
src/main/java/gone/lib/config/ServerConfig.java
src/main/java/gone/lib/config/ServerConfig.java
+3
-2
No files found.
src/main/java/gone/lib/common/ClientRole.java
View file @
31199daa
package
gone.lib.common
;
/**
* Created by winfr on 27.09.2016.
* enum to store the different roles clients can have
*
* @author winfried
*/
public
enum
ClientRole
{
Player
,
...
...
src/main/java/gone/lib/common/NetworkConstants.java
View file @
31199daa
package
gone.lib.common
;
/**
* Created by Winfried on 23.09.2016.
* constant strings we regularly use for the network communication
*
* @author Winfried
*/
public
final
class
NetworkConstants
{
public
static
final
String
STARTINGLINE
=
"--..--"
;
...
...
src/main/java/gone/lib/common/RcStandard.java
View file @
31199daa
package
gone.lib.common
;
/**
* Created by matthias on 22.06.16.
* store the different possible rc standards
*
* @author matthias
*/
public
enum
RcStandard
{
ICWS88
,
...
...
src/main/java/gone/lib/config/ClientConfig.java
View file @
31199daa
...
...
@@ -22,6 +22,17 @@ public class ClientConfig extends ConfigParameters {
/* constructor */
/**
* constructor
* @param width the width of the active window (ui)
* @param height the height of the active window (ui)
* @param warriorName the name of the warrior
* @param pathToRcFile the default path to the redcode file
* @param inetAddress the last used server address
* @param portLastServer the port that fits to that server address
* @param rcStandard the last used rc standard
* @param language the last used language
*/
public
ClientConfig
(
int
width
,
int
height
,
String
warriorName
,
String
pathToRcFile
,
InetAddress
inetAddress
,
int
portLastServer
,
RcStandard
rcStandard
,
Language
language
)
{
...
...
src/main/java/gone/lib/config/ConfigParameters.java
View file @
31199daa
package
gone.lib.config
;
/**
* parent class for server config and client config
*
* @author matthias
*/
public
class
ConfigParameters
{
...
...
src/main/java/gone/lib/config/ConfigTypes.java
View file @
31199daa
package
gone.lib.config
;
/**
* possible configuration types
*
* @author matthias
*/
public
enum
ConfigTypes
{
...
...
src/main/java/gone/lib/config/LoadConfigFile.java
View file @
31199daa
...
...
@@ -12,8 +12,9 @@ import java.util.prefs.InvalidPreferencesFormatException;
import
java.util.prefs.Preferences
;
/**
* loads the default
/ user config file
* loads the default
/user config file (client, server)
* the config file is stored as a preferences file (xml key=value, utf8)
* xml dtd used: http://java.sun.com/dtd/preferences.dtd
*
* @author matthias
*/
...
...
@@ -22,6 +23,10 @@ public class LoadConfigFile {
/* constructor */
/**
* empty constructor, because we set the ConfigParameters variable
* later via a call to either loadClientPrefs or loadServerPrefs
*/
public
LoadConfigFile
()
{
this
.
configParameters
=
new
ConfigParameters
();
}
...
...
@@ -35,14 +40,16 @@ public class LoadConfigFile {
/* class methods */
/**
* loads a config pref file, transfer it into a intern ClientConfig object
* loads a c
lient c
onfig pref file, transfer it into a intern ClientConfig object
* @param defaultFilePath location of the default config file
* @param userFilePath location of the user config file
* @throws IOException if file not found
* @throws IllegalArgumentException
* @param configTypes type of the config to be loaded
* @throws IOException if the file is not found
* @throws InvalidPreferencesFormatException preferences are not formatted correct (xml dtd)
*/
public
void
loadClientPrefs
(
String
defaultFilePath
,
String
userFilePath
,
ConfigTypes
configTypes
)
throws
IOException
,
IllegalArgumentException
,
InvalidPreferencesFormatException
{
throws
IOException
,
InvalidPreferencesFormatException
{
String
nodeName
=
configTypes
.
toString
();
// create and load default prefs
...
...
@@ -71,6 +78,13 @@ public class LoadConfigFile {
userPrefs
.
getInt
(
"SERVER_PORT"
,
65500
),
rcStd
,
defLang
);
}
/**
* loads a server config pref file, transfer it into a intern ClientConfig object
* @param path location of the config file
* @param configTypes type of the config to be loaded
* @throws IOException if the file is not found
* @throws InvalidPreferencesFormatException preferences are not formatted correct
*/
public
void
loadServerPrefs
(
String
path
,
ConfigTypes
configTypes
)
throws
IOException
,
InvalidPreferencesFormatException
{
...
...
src/main/java/gone/lib/config/SaveConfigFile.java
View file @
31199daa
...
...
@@ -11,7 +11,8 @@ import java.util.prefs.Preferences;
/**
* updates the user config file with new values
* the config file is stored as a key=value file, we use: java.util.Properties
* the config file is stored as a preferences file (xml key=value, utf8)
* xml dtd used: http://java.sun.com/dtd/preferences.dtd
*
* @author matthias
*/
...
...
@@ -32,15 +33,15 @@ public class SaveConfigFile {
}
/**
*
* transfer the config parameters to a property file
and save this
* to
our
user config file
* @param params our
object with
the actual parameters
* @param userFilePath
where the user config file is located (absolute path)
* @
throws IllegalArgumentException
* @throws IOException
*
transfer the config parameters to a preferences object
and save this
* to
the
user config file
* @param params our
client config object that stores
the actual parameters
* @param userFilePath
location to save the config file
* @
param nodeName string representing the config type
* @throws IOException
if file is not found
*/
private
void
saveClientConfig
(
ClientConfig
params
,
String
userFilePath
,
String
nodeName
)
throws
I
llegalArgumentException
,
I
OException
{
throws
IOException
{
if
(
userFilePath
.
isEmpty
())
{
throw
new
IllegalArgumentException
(
"user file path should not be empty!"
);
...
...
@@ -78,6 +79,14 @@ public class SaveConfigFile {
out
.
close
();
}
/**
* transfer the config parameters to a preferences object and save this
* to the user config file
* @param params our client config object that stores the actual parameters
* @param userFilePath location to save the config file
* @param nodeName string representing the config type
* @throws IOException if file is not found
*/
private
void
saveServerConfig
(
ServerConfig
params
,
String
userFilePath
,
String
nodeName
)
throws
IOException
{
...
...
src/main/java/gone/lib/config/ServerConfig.java
View file @
31199daa
...
...
@@ -49,8 +49,9 @@ public class ServerConfig extends ConfigParameters {
}
public
void
setPort
(
int
port
)
{
if
(
port
<
0
||
port
>
65535
)
{
throw
new
IllegalArgumentException
(
"port must be >= 0 && <= 65535"
);
// well know ports, tcp range
if
(
port
<
1024
||
port
>
65535
)
{
throw
new
IllegalArgumentException
(
"port must be >= 1024 && <= 65535"
);
}
this
.
port
=
port
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment