An explanation of the operations in the ASP. NET SignalR Hub class

Source: Internet
Author: User

Operations in the Hub class

On the server we're going to do a series of operations through the hub class, so let's talk about what we can do.

Send Message operation for client

Call the Helloclient method for all clients

Clients.All.helloClient ();

Call the Helloclient method for all clients except for a given ConnectionID client

Clients.allexcept (Context.connectionid). Helloclient ();

Invokes the Helloclient method of the specified ConnectionID client

Clients.client (Context.connectionid). Helloclient ();

Calls the Helloclient method to the client of the specified ConnectionID collection

Clients.clients (New list<string> () {"Client1", "Client2"}). Helloclient ();

Invokes all client helloclient methods in a group with the specified name, this method has overloads and can specify the excluded ConnectionID

Clients.group ("Room1"). Helloclient ();

Invokes the Helloclient method for all clients of the specified group collection, which has overloads that can specify the excluded ConnectionID

Clients.groups (New list<string> () {"Room1", "Room2"}). Helloclient ();

Group operations

Remember that in a persistent connection class, you can add members to a group and delete members, which you can do in a hub.

Add action

Groups.add (this. Context.connectionid, "room1");

Delete operation

Groups.remove (this. Context.connectionid, "room1");

Note: User and users in clients are not explained because they are related to authentication and are left to the post for further explanation.

An explanation of the operations in the ASP. NET SignalR Hub class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.