Advertisement
Guest User

Untitled

a guest
Jul 19th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. class Program
  2. {
  3. static void Main(string[] args)
  4. {
  5. string url =
  6. @"http://localhost:8080/";
  7. using (WebApp.Start<Startup>(url))
  8. {
  9. Console.WriteLine(string.Format("Server
  10. running at {0}", url));
  11. Console.ReadLine();
  12. }
  13.  
  14. }
  15. }
  16. public class Test : Hub
  17. {
  18. public void S(string message)
  19. {
  20. Clients.All.R(message);
  21. }
  22.  
  23. }
  24.  
  25. public class Startup
  26. {
  27. public void Configuration(IAppBuilder app)
  28. {
  29. app.UseCors(CorsOptions.AllowAll);
  30. app.MapSignalR();
  31. }
  32. }
  33.  
  34. class Program
  35. {
  36. static void Main(string[] args)
  37. {
  38.  
  39. IHubProxy _hub;
  40. string url = @"http://localhost:8080/";
  41. var connection = new HubConnection(url);
  42. _hub = connection.CreateHubProxy("Test");
  43. connection.Start().Wait();
  44. string line=Console.ReadLine();
  45. _hub.Invoke("S", line).Wait();
  46. _hub.On("R", x => Console.WriteLine(x));
  47. Console.ReadLine();
  48.  
  49.  
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement