HomeController.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using System;
  2. using System.Web.Mvc;
  3. using Abp.Web.Mvc.Controllers;
  4. using IwbZero.ToolCommon.StringModel;
  5. using WeEngine.Message;
  6. namespace WeEngine.Controllers
  7. {
  8. public class HomeController : AbpController
  9. {
  10. public HomeController(WeEngineMsgClientManager msgClient)
  11. {
  12. MsgClient = msgClient;
  13. }
  14. private WeEngineMsgClientManager MsgClient { get; }
  15. public ActionResult Index()
  16. {
  17. return View();
  18. }
  19. public ActionResult Test(string id)
  20. {
  21. string msg = id.IsEmpty() ? new Random().Next(1000, 9999) + "" : id;
  22. MsgClient.SendMessage("WeApp", $"Engine发送测试消息:{msg}");
  23. return View("Index");
  24. }
  25. public ActionResult Refresh()
  26. {
  27. MsgClient.RefreshClient();
  28. return View("Index");
  29. }
  30. public ActionResult Send(string id,string topic=null)
  31. {
  32. topic = topic ?? "WeApp";
  33. string msg = id.IsEmpty() ? new Random().Next(1000, 9999) + "" : id;
  34. MsgClient.SendMessage(topic, $"Engine发送测试消息:{msg}");
  35. return Content("OK");
  36. }
  37. public ActionResult RefreshClient()
  38. {
  39. MsgClient.RefreshClient();
  40. return Content("OK");
  41. }
  42. }
  43. }