Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
BattleArena
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Scherbaum Maximilian
BattleArena
Commits
5c5dabbc
Commit
5c5dabbc
authored
1 year ago
by
Elrabu
Browse files
Options
Downloads
Patches
Plain Diff
Fix: Test server can now store integer variables.
parent
47c8e7bf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!74
V1
,
!73
Initial commit
,
!71
Merge DataBase into Development
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/TestServer/Server.java
+5
-10
5 additions, 10 deletions
...gart/battlearena/Model/Multiplayer/TestServer/Server.java
with
5 additions
and
10 deletions
src/main/java/de/hdm_stuttgart/battlearena/Model/Multiplayer/TestServer/Server.java
+
5
−
10
View file @
5c5dabbc
package
de.hdm_stuttgart.battlearena.Model.Multiplayer.TestServer
;
import
de.hdm_stuttgart.battlearena.Model.Multiplayer.ConnectionHandler
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
java.net.*
;
import
java.io.*
;
public
class
Server
{
private
ServerSocket
serverSocket
;
private
static
BufferedReader
px
;
public
static
void
main
(
String
[]
args
)
throws
IOException
{
Server
server
=
new
Server
();
server
.
start
(
4444
);
server
.
start
(
"lolcalhost"
,
4444
);
}
public
void
start
(
int
port
)
throws
IOException
{
public
void
start
(
String
lolcalhost
,
int
port
)
throws
IOException
{
serverSocket
=
new
ServerSocket
(
port
);
while
(
true
)
new
EchoClientHandler
(
serverSocket
.
accept
()).
start
();
...
...
@@ -33,6 +27,7 @@ public class Server {
private
Socket
clientSocket
;
private
PrintWriter
out
;
private
BufferedReader
in
;
private
static
BufferedReader
px
;
public
EchoClientHandler
(
Socket
socket
)
{
this
.
clientSocket
=
socket
;
...
...
@@ -47,7 +42,7 @@ public class Server {
px
=
in
;
while
(
true
)
{
System
.
out
.
println
(
"Received message from client: "
+
input
Line
);
System
.
out
.
println
(
"Received message from client: "
+
px
.
read
Line
()
);
if
(
inputLine
.
equals
(
0
))
{
out
.
println
(
"bye"
);
...
...
@@ -58,7 +53,7 @@ public class Server {
out
.
println
(
px
);
out
.
flush
();
System
.
out
.
println
(
"Sent response to client: "
+
px
);
System
.
out
.
println
(
"Sent response to client: "
+
px
.
readLine
()
);
}
}
catch
(
SocketException
e
)
{
System
.
out
.
println
(
"Client connection reset."
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment