dsuryd / dotNetify

Simple, lightweight, yet powerful way to build real-time web apps.
https://dotnetify.net
Other
1.17k stars 164 forks source link

Accessing groups and users #128

Closed larsbuch closed 5 years ago

larsbuch commented 6 years ago

It would be nice to have an example of how to access SignalR Clients and Groups either from Middleware or from VM

dsuryd commented 6 years ago

Take a look at the MulticastVM API doc and the Chat Room example.

On Mon, Oct 15, 2018 at 7:39 PM Lars Shakya Buch-Jepsen < notifications@github.com> wrote:

It would be nice to have an example of how to access SignalR Clients and Groups either from Middleware or from VM

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/dsuryd/dotNetify/issues/128, or mute the thread https://github.com/notifications/unsubscribe-auth/AOS8khp9W01R5HtMBEOAHAioisyCtTw1ks5ulUbFgaJpZM4XdeBT .

bugged84 commented 6 years ago

@larsbuch here are links for MulticastVM API and the Chat Room example

larsbuch commented 6 years ago

I have been looking at the MulticastVM/BaseVM and Chat Room examples. I have not found it in either.

@bugged84 : It is not nice to make issue hijacking for irrelevant information. Normally you should open a new issue for the discussion.

dsuryd commented 6 years ago

@larsbuch: I may not be understanding you; what kind of example you're looking for? MulticastVM provides a Send method to send message to any SignalR clients and groups. For direct access to SignalR APIs, inject their IHubContext as documented in SignalR website.

@bugged84: Please create a new issue for us to discuss on how to implement group chat rooms.

larsbuch commented 6 years ago

I can see that the used signalr hub is DotNetifyHub

The way to access Groups and Users is through IHubContext context = GlobalHost.ConnectionManager.GetHubContext<DotNetifyHub>();

bugged84 commented 5 years ago

@dsuryd do you have an example of the MulticastVM Send method that you referred to above? Does the second argument propertyName refer to the name of a property on the React component's state object?

bugged84 commented 5 years ago

I set propertyName to "hello" and propertyValue to "world" and the following was logged in the browser console.

[ChatRoomLobby] received>
{hello: "world"}

What can be done with this? For example, what if I want the React component to display the value of the hello property? How can this be done?

dsuryd commented 5 years ago

The chat room example uses the Send method to send private message to chat users.