You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
965 B
26 lines
965 B
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Http.Extensions;
|
|
using Microsoft.AspNetCore.SignalR;
|
|
|
|
namespace SingalDemo
|
|
{
|
|
public class PageHub : Hub
|
|
{
|
|
public override Task OnConnectedAsync()
|
|
{
|
|
Console.WriteLine($"{Context.ConnectionId} has connected which request url is {Context.GetHttpContext().Request.GetEncodedUrl()}");
|
|
if (Context.GetHttpContext().Request.Query.Keys.Contains("group"))
|
|
{
|
|
this.Groups.AddToGroupAsync(Context.ConnectionId, Context.GetHttpContext().Request.Query["group"]);
|
|
}
|
|
return base.OnConnectedAsync();
|
|
}
|
|
|
|
public override Task OnDisconnectedAsync(Exception exception)
|
|
{
|
|
Console.WriteLine($"{Context.ConnectionId} has disconnected which request url is {Context.GetHttpContext().Request.GetEncodedUrl()}");
|
|
return base.OnDisconnectedAsync(exception);
|
|
}
|
|
}
|
|
} |