Article From:https://www.cnblogs.com/vbing/p/9967358.html

SignalR Design Idea (1)

Realize real-time communication between client and server.

public void Send(string message) { Clients.All.Write(message); // Clients.All.write(message); It's fine too.}

How would you design the server architecture for the above problems?

SignalR selectiondynamic Dynamic data type is the base class of client communication.

Q:

  1. How can dynamic data types address client-side uncertainty?1
  2. How can dynamic data types solve the uncertainty of client method parameters?2
  3. How do dynamic data types distinguish between client methods to be invoked?3

to cite one against three”:

  1. Why does the server call client ignore case?

Core code:

public class ClientProxy : DynamicObject
{
   [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Binder is passed in by the DLR")]
    public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
    {
        result = Invoke(binder.Name, args);
        return true;
    }
    /// <summary>
    /// Processing business logic here/ / / < /summary>// lt; param name = "method" & gt; method name & lt; / param & gt;/ / / <Param name = "args" & gt; Parameter & lt; / param & gt;// lt; returns & gt; & lt; / returns & gt;Public Task Invoke(string method, params object [] args){Return Task. Factory. StartNew () =>{/ / Processing business logic here.};}}

  1. adoptbinder.Name Determine the client method name. A kind of

  2. adoptargs Determine the client method parameters. A kind of

  3. Through [^ 1] and [^ 2] two points to determine the client’s designated method. A kind of

Link of this Article: SignalR Design Concept (I)

Leave a Reply

Your email address will not be published. Required fields are marked *