Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
Zsirozas
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sillinger Péter
Zsirozas
Commits
c8b6ac62
Commit
c8b6ac62
authored
Mar 11, 2020
by
Sillinger Péter
Browse files
Options
Downloads
Patches
Plain Diff
Fixed communication bug.
parent
eea597ac
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
zsirozas/Common.cs
+1
-1
1 addition, 1 deletion
zsirozas/Common.cs
zsirozas/Game.cs
+4
-3
4 additions, 3 deletions
zsirozas/Game.cs
zsirozas/GameClient.cs
+19
-13
19 additions, 13 deletions
zsirozas/GameClient.cs
zsirozas/RawTcpTransport.cs
+1
-1
1 addition, 1 deletion
zsirozas/RawTcpTransport.cs
with
25 additions
and
18 deletions
zsirozas/Common.cs
+
1
−
1
View file @
c8b6ac62
...
@@ -48,7 +48,7 @@ namespace zsirozas
...
@@ -48,7 +48,7 @@ namespace zsirozas
/// </summary>
/// </summary>
/// <param name="s">a message that will be written to the network stream</param>
/// <param name="s">a message that will be written to the network stream</param>
void
SendMessage
(
string
s
);
void
SendMessage
(
string
s
);
void
ParseNextMessage
(
Stream
s
,
object
param
);
void
ParseNextMessage
(
Stream
Reader
sr
);
bool
ValidateConnection
(
object
connInfo
);
bool
ValidateConnection
(
object
connInfo
);
}
}
...
...
This diff is collapsed.
Click to expand it.
zsirozas/Game.cs
+
4
−
3
View file @
c8b6ac62
...
@@ -16,8 +16,8 @@ namespace zsirozas
...
@@ -16,8 +16,8 @@ namespace zsirozas
public
void
NotifyPlayers
(
GameEvent
@event
)
public
void
NotifyPlayers
(
GameEvent
@event
)
{
{
string
prefix
=
ServerEvent
.
GameEvent
+
"\n"
;
//
string prefix = ServerEvent.GameEvent + "\n";
string
message
=
prefix
+
@event
;
string
message
=
""
;
//
prefix + @event;
switch
(
@event
)
switch
(
@event
)
{
{
case
GameEvent
.
CardAction
:
case
GameEvent
.
CardAction
:
...
@@ -48,7 +48,8 @@ namespace zsirozas
...
@@ -48,7 +48,8 @@ namespace zsirozas
}
}
for
(
int
i
=
0
;
i
<
playersByOrder
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
playersByOrder
.
Length
;
i
++)
{
{
gameServer
.
UsersByID
[
playersByOrder
[
i
]].
client
.
SendMessage
(
message
);
//gameServer.UsersByID[playersByOrder[i]].client.SendMessage(message);
gameServer
.
UsersByID
[
playersByOrder
[
i
]].
client
.
InGameNotify
(
GameEvent
.
GameOver
,
message
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
zsirozas/GameClient.cs
+
19
−
13
View file @
c8b6ac62
...
@@ -121,17 +121,22 @@ namespace zsirozas
...
@@ -121,17 +121,22 @@ namespace zsirozas
void
ListenForServer
()
void
ListenForServer
()
{
{
try
using
(
var
sr
=
new
StreamReader
(
messageStream
))
{
{
while
(
true
)
while
(
true
)
{
{
ParseNextMessage
(
messageStream
,
null
);
try
}
{
ParseNextMessage
(
sr
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
//TODO: rossz debug módszer....
handleServerError
(
this
,
ex
.
Message
);
return
;
return
;
}
}
}
}
//using (var sr = new StreamReader(messageStream))
//using (var sr = new StreamReader(messageStream))
//{
//{
// string line = "";
// string line = "";
...
@@ -217,9 +222,9 @@ namespace zsirozas
...
@@ -217,9 +222,9 @@ namespace zsirozas
throw
new
NotImplementedException
();
throw
new
NotImplementedException
();
}
}
public
void
ParseNextMessage
(
Stream
s
,
object
param
)
public
void
ParseNextMessage
(
Stream
Reader
sr
)
{
{
using
(
var
sr
=
new
StreamReader
(
s
))
//
using (var sr = new StreamReader(s))
{
{
try
try
{
{
...
@@ -231,7 +236,7 @@ namespace zsirozas
...
@@ -231,7 +236,7 @@ namespace zsirozas
var
@event
=
(
ServerEvent
)
Enum
.
Parse
(
typeof
(
ServerEvent
),
line
);
var
@event
=
(
ServerEvent
)
Enum
.
Parse
(
typeof
(
ServerEvent
),
line
);
if
(
@event
==
ServerEvent
.
GameEvent
)
if
(
@event
==
ServerEvent
.
GameEvent
)
{
{
ParseGameMessage
(
sr
,
param
);
ParseGameMessage
(
sr
);
}
}
else
else
{
{
...
@@ -253,14 +258,15 @@ namespace zsirozas
...
@@ -253,14 +258,15 @@ namespace zsirozas
}
}
}
}
}
}
private
void
ParseGameMessage
(
StreamReader
sr
,
object
param
)
private
void
ParseGameMessage
(
StreamReader
sr
)
{
{
//TODO: validálni
//TODO: validálni
string
line
=
sr
.
ReadLine
();
string
line
=
sr
.
ReadLine
();
GameEvent
gameEvent
;
if
(
Enum
.
TryParse
(
line
,
out
GameEvent
gameEvent
))
Enum
.
TryParse
(
line
,
out
gameEvent
);
{
InGameNotify
(
gameEvent
,
sr
.
ReadLine
());
InGameNotify
(
gameEvent
,
sr
.
ReadLine
());
}
}
}
public
void
InGameNotify
(
GameEvent
@event
,
string
param0
)
public
void
InGameNotify
(
GameEvent
@event
,
string
param0
)
{
{
...
...
This diff is collapsed.
Click to expand it.
zsirozas/RawTcpTransport.cs
+
1
−
1
View file @
c8b6ac62
...
@@ -68,7 +68,7 @@ namespace zsirozas
...
@@ -68,7 +68,7 @@ namespace zsirozas
return
false
;
return
false
;
}
}
public
void
ParseNextMessage
(
Stream
s
,
object
param
)
public
void
ParseNextMessage
(
Stream
Reader
sr
)
{
{
throw
new
NotSupportedException
(
"This is a proxy to the real app client. You shouldn't want to feed it message streams."
);
throw
new
NotSupportedException
(
"This is a proxy to the real app client. You shouldn't want to feed it message streams."
);
}
}
...
...
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