You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
627 B
26 lines
627 B
#if !NET20
|
|
|
|
using System;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
|
|
namespace Apewer.WebSocket
|
|
{
|
|
internal static class SubProtocolNegotiator
|
|
{
|
|
public static string Negotiate(IEnumerable<string> server, IEnumerable<string> client)
|
|
{
|
|
if (!server.Any() || !client.Any()) {
|
|
return null;
|
|
}
|
|
|
|
var matches = client.Intersect(server);
|
|
if (!matches.Any()) {
|
|
throw new SubProtocolNegotiationFailureException("Unable to negotiate a subprotocol");
|
|
}
|
|
return matches.First();
|
|
}
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|