Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose hub interface for use within HubContext #59

Open
dealproc opened this issue Feb 21, 2019 · 2 comments
Open

Expose hub interface for use within HubContext #59

dealproc opened this issue Feb 21, 2019 · 2 comments
Assignees

Comments

@dealproc
Copy link

Within this example code:

public class UserNotificationGrain : Grain<UserNotificationState>, IUserNotificationGrain
{
	private HubContext<IUserNotificationHub> _hubContext;

	public override async Task OnActivateAsync()
	{
		_hubContext = GrainFactory.GetHub<IUserNotificationHub>();
		// some code...
		await _hubContext.User(this.GetPrimaryKeyString()).SendSignalRMessage("Broadcast", State.UserNotification);
	}
}

It would be decent if the IUserNotificationHub interface could have methods that are implemented on the client to be exposed to the Grain code.

In the case of the example code, the changes would look something like:

public interface IUserNotificationHub
{
    task Broadcast(UserNotification);
}

public class UserNotificationGrain : Grain<UserNotificationState>, IUserNotificationGrain
{
	private HubContext<IUserNotificationHub> _hubContext;

	public override async Task OnActivateAsync()
	{
		_hubContext = GrainFactory.GetHub<IUserNotificationHub>();
		// some code...
		await _hubContext.User(this.GetPrimaryKeyString()).Broadcast(State.UserNotification);
	}
}

Which would cleanup the server code.

@galvesribeiro
Copy link
Member

Not sure this is desired... @claylaut may have some extra thoughts on it...

@claylaut
Copy link
Collaborator

@galvesribeiro it's nice to have feature.

@claylaut claylaut self-assigned this May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants