SocketClientCache.cs 528 B

1234567891011121314151617
  1. using InABox.Client.WebSocket;
  2. namespace InABox.Clients
  3. {
  4. public static class SocketClientCache
  5. {
  6. private static Dictionary<string, WebSocketClient> Clients = new Dictionary<string, WebSocketClient>();
  7. public static void StartWebSocket(string url, int port, Guid session)
  8. {
  9. Uri uri = new Uri(url);
  10. var key = $"{uri.Host}${session}";
  11. if (!Clients.ContainsKey(key))
  12. Clients[key] = new WebSocketClient(uri.Host, port, session);
  13. }
  14. }
  15. }