WSConnectionItem.cs 754 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. namespace IFramework.Net.WebSocket
  3. {
  4. public class WSConnectionItem
  5. {
  6. public WSConnectionItem()
  7. { }
  8. public WSConnectionItem(string wsUrl)
  9. {
  10. string[] urlParams = wsUrl.Split(':');
  11. if (urlParams.Length < 3)
  12. throw new Exception("wsUrl is error format.for example as ws://localhost:80");
  13. Proto = urlParams[0];
  14. Domain = urlParams[1].Replace("//", "");
  15. Port = int.Parse(urlParams[2]);
  16. Host = Domain + ":" + Port;
  17. }
  18. public string Proto { get; set; } = "ws";
  19. public string Domain { get; set; }
  20. public int Port { get; set; } = 65531;
  21. public string Host { get; }
  22. }
  23. }