Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
dc84b5e4
Commit
dc84b5e4
authored
Mar 03, 2021
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
no message
parent
bab0aefb
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
22 deletions
+10
-22
performance/Performance.Services/Hubs/AllotLogHub.cs
+7
-18
performance/Performance.Services/Hubs/NotificationsService.cs
+3
-4
No files found.
performance/Performance.Services/Hubs/AllotLogHub.cs
View file @
dc84b5e4
...
...
@@ -26,32 +26,21 @@ NotificationsService service
this
.
logger
=
logger
;
this
.
service
=
service
;
}
private
readonly
MemoryCacheHelper
helper
=
new
MemoryCacheHelper
();
public
override
Task
OnConnectedAsync
()
{
var
task
=
base
.
OnConnectedAsync
();
Clients
.
Caller
.
SendAsync
(
"ReceiveMessage"
,
Context
.
ConnectionId
);
return
task
;
}
public
override
Task
OnDisconnectedAsync
(
Exception
exception
)
{
return
base
.
OnDisconnectedAsync
(
exception
);
}
private
readonly
MemoryCacheHelper
helper
=
new
MemoryCacheHelper
();
public
void
LoginService
(
int
userId
)
{
//
var dateTime = DateTime.Now;
//
var slidingtimespan = helper.ToUnixTimestampBySeconds(dateTime.AddMinutes(30));
//
var absolutetimespan = helper.ToUnixTimestampBySeconds(dateTime.AddHours(2));
//
helper.Set(userId.ToString(), Context.ConnectionId, slidingtimespan, absolutetimespan);
var
dateTime
=
DateTime
.
Now
;
var
slidingtimespan
=
helper
.
ToUnixTimestampBySeconds
(
dateTime
.
AddMinutes
(
30
));
var
absolutetimespan
=
helper
.
ToUnixTimestampBySeconds
(
dateTime
.
AddHours
(
2
));
helper
.
Set
(
userId
.
ToString
(),
Context
.
ConnectionId
,
slidingtimespan
,
absolutetimespan
);
}
public
void
LogoutService
(
int
userId
)
{
//
if (helper.Exists(userId.ToString()))
//
helper.Remove(userId.ToString());
if
(
helper
.
Exists
(
userId
.
ToString
()))
helper
.
Remove
(
userId
.
ToString
());
}
}
}
performance/Performance.Services/Hubs/NotificationsService.cs
View file @
dc84b5e4
...
...
@@ -12,19 +12,18 @@ public class NotificationsService : IAutoInjection
{
private
readonly
ILogger
logger
;
private
readonly
IHubContext
<
AllotLogHub
>
hubContext
;
private
readonly
MemoryCacheHelper
helper
;
public
NotificationsService
(
ILogger
<
NotificationsService
>
logger
,
IHubContext
<
AllotLogHub
>
hubContext
,
MemoryCacheHelper
helper
IHubContext
<
AllotLogHub
>
hubContext
)
{
this
.
logger
=
logger
;
this
.
hubContext
=
hubContext
;
this
.
helper
=
helper
;
}
private
readonly
MemoryCacheHelper
helper
=
new
MemoryCacheHelper
();
public
void
SendMessage
(
int
userId
,
MessageInfo
data
)
{
string
key
=
userId
.
ToString
();
...
...
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