This repository has been archived by the owner on Nov 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
12 changed files
with
108 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Collections.Generic; | ||
using System.Net.WebSockets; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.AspNet.Http | ||
{ | ||
public abstract class WebSocketManager | ||
{ | ||
public abstract bool IsWebSocketRequest { get; } | ||
|
||
public abstract IList<string> WebSocketRequestedProtocols { get; } | ||
|
||
public virtual Task<WebSocket> AcceptWebSocketAsync() | ||
{ | ||
return AcceptWebSocketAsync(subProtocol: null); | ||
} | ||
|
||
public abstract Task<WebSocket> AcceptWebSocketAsync(string subProtocol); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
src/Microsoft.AspNet.Http.Interfaces/IWebSocketAcceptContext.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Net.WebSockets; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNet.FeatureModel; | ||
using Microsoft.AspNet.Http.Infrastructure; | ||
using Microsoft.Net.Http.Headers; | ||
|
||
namespace Microsoft.AspNet.Http | ||
{ | ||
public class DefaultWebSocketManager : WebSocketManager | ||
{ | ||
private static IList<string> EmptyList = new List<string>(); | ||
|
||
private IFeatureCollection _features; | ||
private FeatureReference<IHttpRequestFeature> _request = FeatureReference<IHttpRequestFeature>.Default; | ||
private FeatureReference<IHttpWebSocketFeature> _webSockets = FeatureReference<IHttpWebSocketFeature>.Default; | ||
|
||
public DefaultWebSocketManager(IFeatureCollection features) | ||
{ | ||
_features = features; | ||
} | ||
|
||
private IHttpRequestFeature HttpRequestFeature | ||
{ | ||
get { return _request.Fetch(_features); } | ||
} | ||
|
||
private IHttpWebSocketFeature WebSocketFeature | ||
{ | ||
get { return _webSockets.Fetch(_features); } | ||
} | ||
|
||
public override bool IsWebSocketRequest | ||
{ | ||
get | ||
{ | ||
return WebSocketFeature != null && WebSocketFeature.IsWebSocketRequest; | ||
} | ||
} | ||
|
||
public override IList<string> WebSocketRequestedProtocols | ||
{ | ||
get | ||
{ | ||
return ParsingHelpers.GetHeaderUnmodified(HttpRequestFeature.Headers, | ||
HeaderNames.WebSocketSubProtocols) ?? EmptyList; | ||
} | ||
} | ||
|
||
public override Task<WebSocket> AcceptWebSocketAsync(string subProtocol) | ||
{ | ||
if (WebSocketFeature == null) | ||
{ | ||
throw new NotSupportedException("WebSockets are not supported"); | ||
} | ||
return WebSocketFeature.AcceptAsync(new WebSocketAcceptContext() { SubProtocol = subProtocol }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters