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
76a6cd4d
Commit
76a6cd4d
authored
May 7, 2020
by
Sillinger Péter
Browse files
Options
Downloads
Patches
Plain Diff
Included SignalRTrasport.cs.
parent
d0154eda
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
zsirozas/Common.cs
+1
-1
1 addition, 1 deletion
zsirozas/Common.cs
zsirozas/SignalR-Transport.cs
+130
-0
130 additions, 0 deletions
zsirozas/SignalR-Transport.cs
zsirozas/zsirozas.csproj
+1
-0
1 addition, 0 deletions
zsirozas/zsirozas.csproj
with
132 additions
and
1 deletion
zsirozas/Common.cs
+
1
−
1
View file @
76a6cd4d
...
@@ -17,7 +17,7 @@ namespace zsirozas
...
@@ -17,7 +17,7 @@ namespace zsirozas
string
CreateUser
(
string
nickname
,
ConnectionType
type
,
object
backTalk
);
string
CreateUser
(
string
nickname
,
ConnectionType
type
,
object
backTalk
);
void
RemoveUser
(
string
userID
);
void
RemoveUser
(
string
userID
);
string
NewGame
(
string
roomID
);
string
NewGame
(
string
roomID
);
//TODO: hozzáadni hogy (string userID,...)
string
[]
ListRooms
();
string
[]
ListRooms
();
string
[]
ListUsers
();
string
[]
ListUsers
();
ServerInfo
ServerInfo
();
ServerInfo
ServerInfo
();
...
...
This diff is collapsed.
Click to expand it.
zsirozas/SignalR-Transport.cs
0 → 100644
+
130
−
0
View file @
76a6cd4d
using
System
;
using
System.Threading.Tasks
;
using
Microsoft.AspNet.SignalR
;
//és a klienshez
using
Microsoft.AspNet.SignalR.Client
;
using
Microsoft.AspNet.SignalR.Client.Transports
;
namespace
zsirozas
{
//............................................................
class
SignalRRemoteServer
:
IServerApiProvider
{
IHubProxy
hub
;
public
string
CreateUser
(
string
name
,
ConnectionType
type
,
object
backTalk
)
{
return
hub
.
Invoke
<
string
>(
nameof
(
CreateUser
),
name
,
type
,
backTalk
).
Result
;
}
public
string
CreateRoom
(
string
userID
)
{
return
hub
.
Invoke
<
string
>(
nameof
(
CreateRoom
),
userID
).
Result
;
}
public
void
LeaveRoom
(
string
userID
)
{
hub
.
Invoke
(
nameof
(
LeaveRoom
),
userID
).
Wait
();
}
public
void
JoinRoom
(
string
userID
,
string
roomID
)
{
hub
.
Invoke
(
nameof
(
JoinRoom
),
roomID
).
Wait
();
}
public
void
RemoveUser
(
string
userID
)
{
hub
.
Invoke
(
nameof
(
RemoveUser
),
userID
).
Wait
();
}
public
string
NewGame
(
string
roomID
)
{
return
hub
.
Invoke
<
string
>(
nameof
(
NewGame
),
roomID
).
Result
;
}
IAppClient
client
;
public
SignalRRemoteServer
(
string
server_url
)
{
hub
=
new
HubConnection
(
server_url
).
CreateHubProxy
(
nameof
(
SignalRServerHub
));
hub
.
On
<
ServerEvent
,
object
>(
nameof
(
client
.
SimpleNotify
),
client
.
SimpleNotify
);
hub
.
On
<
GameEvent
,
object
>(
nameof
(
client
.
InGameNotify
),
client
.
InGameNotify
);
}
}
//................................................................................
class
SignalRServerHub
:
Hub
<
IAppClient
>,
IServerApiProvider
{
//a hubok tranziesnek, úgyhogy ezt csak így tudom értelmesen
//TODO: van-e ennek "szebb" módja?
public
static
IServerApiProvider
appServer
=
new
ActualServer
();
public
SignalRServerHub
(
IServerApiProvider
serverInstance
)
{
appServer
=
serverInstance
;
}
public
string
CreateUser
(
string
name
,
ConnectionType
type
,
object
backTalk
)
{
switch
(
type
)
{
case
ConnectionType
.
SignalR
:
if
(
backTalk
!=
null
)
goto
default
;
backTalk
=
Context
.
ConnectionId
;
break
;
case
ConnectionType
.
RawTCP
:
throw
new
Exception
(
"What? Why?"
);
default
:
throw
new
NotSupportedException
(
"You can't do that"
);
}
return
appServer
.
CreateUser
(
name
,
type
,
backTalk
);
}
public
string
CreateRoom
(
string
userID
)
{
return
appServer
.
CreateRoom
(
userID
);
}
public
void
LeaveRoom
(
string
userID
)
{
appServer
.
LeaveRoom
(
userID
);
}
public
void
JoinRoom
(
string
userID
,
string
roomID
)
{
appServer
.
JoinRoom
(
userID
,
roomID
);
}
public
void
RemoveUser
(
string
userID
)
{
appServer
.
RemoveUser
(
userID
);
}
public
string
NewGame
(
string
roomID
)
{
return
appServer
.
NewGame
(
roomID
);
}
}
class
AppClientWithSignalR
:
IAppClient
{
public
string
signalRConnID
;
public
AppClientWithSignalR
(
string
backTalk
)
{
this
.
signalRConnID
=
backTalk
;
}
public
void
InGameNotify
(
GameEvent
@event
,
object
param0
)
{
var
context
=
GlobalHost
.
ConnectionManager
.
GetHubContext
<
SignalRServerHub
>();
(
context
as
IAppClient
).
InGameNotify
(
@event
,
param0
);
}
public
void
SimpleNotify
(
ServerEvent
@event
,
object
param0
)
{
var
context
=
GlobalHost
.
ConnectionManager
.
GetHubContext
<
SignalRServerHub
>();
(
context
as
IAppClient
).
SimpleNotify
(
@event
,
param0
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
zsirozas/zsirozas.csproj
+
1
−
0
View file @
76a6cd4d
...
@@ -61,6 +61,7 @@
...
@@ -61,6 +61,7 @@
<Compile
Include=
"Common.cs"
/>
<Compile
Include=
"Common.cs"
/>
<Compile
Include=
"RawTcpTransport.cs"
/>
<Compile
Include=
"RawTcpTransport.cs"
/>
<Compile
Include=
"Rooms.cs"
/>
<Compile
Include=
"Rooms.cs"
/>
<Compile
Include=
"SignalR-Transport.cs"
/>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<None
Include=
"app.config"
/>
<None
Include=
"app.config"
/>
...
...
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