Open GibbOne opened 8 years ago
I tested in my project a simple modification of InternalTryGetServiceHost function in WebSocketServiceManager.cs.
using System.Linq;
using System.Text.RegularExpressions;
internal bool InternalTryGetServiceHost (string path, out WebSocketServiceHost host)
{
bool ret;
lock (_sync) {
path = HttpUtility.UrlDecode (path).TrimEndSlash ();
var results = from result in _hosts
where Regex.Match(path, result.Key, RegexOptions.Singleline).Success
select result;
ret = results.Count() != 0;
host = results.FirstOrDefault().Value;
}
if (!ret)
_logger.Error (
"A WebSocket service with the specified path isn't found:\n path: " + path);
return ret;
}
It works. For sure it can increase connection time but could be done on a new method (like AddWebSocketServiceWithPattern) rather than AddWebSocketService.
In WebSocketServer, could be useful to have a method AddWebSocketService with path argument as a regular expression.
In this way a set of request url could be managed by the same WebSocketBehavior.
Something like what Owin.Websocket does in the following code.
What do you think about this?