Skip to content
Dyshay edited this page Feb 1, 2020 · 5 revisions

How to call function on server ?

CLI : await Connection.InvokeAsync("ReceivedHandler", package, tcpId);

The first params in string is the name of the function

How to call function from server to client (cli)

await Clients.Client(CliID).SendAsync("NewConnection", "34.251.172.139", 443, false, tcpId);

  • CLIiD = the ID of cli
  • NewConnection is the function on client
  • The others params, it's about the function

How to Handle event from server

delegate

public event Action<string, int, bool, string> ConnexionHandler;

function in Hub

Connection.On<string, int, bool, string>("NewConnection", (ip, port, @switch, tcpId) => ConnexionHandler?.Invoke(ip, port, @switch, tcpId));

You need to use a action delegate to dispatch the information

Where apply a method to delete and init this for start the handle

https://github.com/Dyshay/DeepBot/blob/dev/DeepBot.CLI/Service/TalkHubService.cs