Program.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using CLServer.Statistics;
  5. using Sers.Core.CL.CommunicationManage;
  6. using Sers.Core.CL.MessageOrganize;
  7. using Vit.Core.Module.Log;
  8. namespace CLServer
  9. {
  10. class Program
  11. {
  12. static StatisticsQpsInfo qpsInfo = new StatisticsQpsInfo();
  13. static void Main(string[] args)
  14. {
  15. Logger.OnLog = (level, msg) => { Console.Write("[" + level + "]" + msg); };
  16. qpsInfo.Start("Msg");
  17. CommunicationManageServer cm = new CommunicationManageServer();
  18. cm.conn_OnGetMessage = (conn, msg) =>
  19. {
  20. qpsInfo.IncrementRequest();
  21. conn.SendMessageAsync(new List<ArraySegment<byte>> { msg });
  22. };
  23. cm.conn_OnGetRequest = (IOrganizeConnection conn, Object sender, ArraySegment<byte> requestData, Action<object, List<ArraySegment<byte>>> callback) =>
  24. {
  25. qpsInfo.IncrementRequest();
  26. callback(sender,new List<ArraySegment<byte>> { requestData });
  27. };
  28. cm.Conn_OnConnected = (conn) =>
  29. {
  30. Logger.Info("Conn_OnConnected");
  31. };
  32. cm.Conn_OnDisconnected = (conn) =>
  33. {
  34. Logger.Info("Conn_OnDisconnected");
  35. };
  36. cm.Start();
  37. while (true)
  38. {
  39. Thread.Sleep(5000);
  40. }
  41. }
  42. }
  43. }