You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
ikvm-native
libgc
llvm
m4
man
mcs
build
class
Accessibility
Commons.Xml.Relaxng
Cscompmgd
CustomMarshalers
Facades
I18N
IBM.Data.DB2
ICSharpCode.SharpZipLib
Microsoft.Build
Microsoft.Build.Engine
Microsoft.Build.Framework
Microsoft.Build.Tasks
Microsoft.Build.Utilities
Microsoft.CSharp
Microsoft.NuGet.Build.Tasks
Microsoft.VisualC
Microsoft.Web.Infrastructure
MicrosoftAjaxLibrary
Mono.Btls.Interface
Mono.C5
Mono.CSharp
Mono.Cairo
Mono.Cecil
Mono.Cecil.Mdb
Mono.CodeContracts
Mono.CompilerServices.SymbolWriter
Mono.Data.Sqlite
Mono.Data.Tds
Mono.Debugger.Soft
Mono.Http
Mono.Management
Mono.Messaging
Mono.Messaging.RabbitMQ
Mono.Options
Mono.Parallel
Mono.Posix
Mono.Profiler.Log
Mono.Runtime.Tests
Mono.Security
Mono.Security.Win32
Mono.Simd
Mono.Tasklets
Mono.WebBrowser
Mono.XBuild.Tasks
Novell.Directory.Ldap
PEAPI
RabbitMQ.Client
SMDiagnostics
System
System.ComponentModel.Composition.4.5
System.ComponentModel.DataAnnotations
System.Configuration
System.Configuration.Install
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Linq
System.Data.OracleClient
System.Data.Services
System.Data.Services.Client
System.Deployment
System.Design
System.DirectoryServices
System.DirectoryServices.Protocols
System.Drawing
System.Drawing.Design
System.Dynamic
System.EnterpriseServices
System.IO.Compression
System.IO.Compression.FileSystem
System.IdentityModel
System.IdentityModel.Selectors
System.Json
System.Json.Microsoft
System.Management
System.Messaging
System.Net
System.Net.Http
System.Net.Http.Formatting
System.Net.Http.WebRequest
System.Net.Http.WinHttpHandler
System.Numerics
System.Numerics.Vectors
System.Reactive.Core
System.Reactive.Debugger
System.Reactive.Experimental
System.Reactive.Interfaces
System.Reactive.Linq
System.Reactive.Observable.Aliases
System.Reactive.PlatformServices
System.Reactive.Providers
System.Reactive.Runtime.Remoting
System.Reactive.Windows.Forms
System.Reactive.Windows.Threading
System.Reflection.Context
System.Runtime.Caching
System.Runtime.CompilerServices.Unsafe
System.Runtime.DurableInstancing
System.Runtime.Remoting
System.Runtime.Serialization
System.Runtime.Serialization.Formatters.Soap
System.Security
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.Web
System.ServiceProcess
System.Threading.Tasks.Dataflow
System.Transactions
System.Web
System.Web.Abstractions
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Extensions
System.Web.Extensions.Design
System.Web.Http
System.Web.Http.SelfHost
System.Web.Http.WebHost
System.Web.Mobile
System.Web.Mvc3
System.Web.Razor
System.Web.RegularExpressions
System.Web.Routing
System.Web.Services
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
System.Windows
System.Windows.Forms
System.Windows.Forms.DataVisualization
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.XML
System.Xaml
System.Xml.Linq
System.Xml.Serialization
SystemWebTestShim
WebMatrix.Data
WindowsBase
aot-compiler
corlib
dlr
doc
legacy
lib
monodoc
notes
reference-assemblies
referencesource
SMDiagnostics
System
System.Activities
System.Activities.Core.Presentation
System.Activities.DurableInstancing
System.Activities.Presentation
System.ComponentModel.DataAnnotations
System.Configuration
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Entity.Design
System.Data.Linq
System.Data.SqlXml
System.IdentityModel
System.IdentityModel.Selectors
System.Net
System.Numerics
System.Runtime.Caching
System.Runtime.DurableInstancing
System.Runtime.Serialization
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Activities
System.ServiceModel.Channels
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.WasHosting
System.ServiceModel.Web
System.Web
Abstractions
Administration
Cache
Compilation
Configuration
DataAccess
DataAnnotations
Handlers
Hosting
Instrumentation
InternalApis
IntraPartitionAPIs
Management
ModelBinding
Profile
Properties
Routing
Security
State
UI
Util
WebSockets
AspNetWebSocket.cs
AspNetWebSocketContext.cs
AspNetWebSocketContextImpl.cs
AspNetWebSocketManager.cs
AspNetWebSocketOptions.cs
IAsyncAbortableWebSocket.cs
IUnmanagedWebSocketContext.cs
IWebSocketPipe.cs
SubprotocolUtil.cs
UnmanagedWebSocketContext.cs
WebSocketPipe.cs
WebSocketUtil.cs
misc
AspNetEventSource.cs
AspNetSynchronizationContext.cs
AspNetSynchronizationContextBase.cs
BufferAllocator.cs
CachedPathData.cs
CrossSiteScriptingValidation.cs
DefaultHttpHandler.cs
DynamicModuleRegistry.cs
DynamicValidationShim.cs
ErrorFormatter.cs
EtwTrace.cs
EventHandlerTaskAsyncHelper.cs
FileChangesMonitor.cs.REMOVED.git-id
GlobalSuppressions.cs.REMOVED.git-id
GlobalSuppressions2.cs.REMOVED.git-id
GlobalSuppressions3.cs
GlobalSuppressions4.cs
HTTPNotFoundHandler.cs
HtmlString.cs
HttpApplication.cs.REMOVED.git-id
HttpApplicationFactory.cs
HttpAsyncResult.cs
HttpBrowserCapabilities.cs
HttpBufferlessInputStream.cs
HttpCacheParams.cs
HttpCachePolicy.cs
HttpCacheVary.cs
HttpCacheVaryByContentEncodings.cs
HttpChannelBindingToken.cs
HttpClientCertificate.cs
HttpContext.cs
HttpCookie.cs
HttpCookieCollection.cs
HttpDebugHandler.cs
HttpDictionary.cs
HttpException.cs
HttpFileCollection.cs
HttpHeaderCollection.cs
HttpInputStream.cs
HttpModuleCollection.cs
HttpPostedFile.cs
HttpRawResponse.cs
HttpRequest.cs.REMOVED.git-id
HttpResponse.cs.REMOVED.git-id
HttpResponseHeader.cs
HttpRuntime.cs.REMOVED.git-id
HttpServerVarsCollection.cs
HttpTaskAsyncHandler.cs
HttpValueCollection.cs
HttpWriter.cs
IHtmlString.cs
IHttpAsyncHandler.cs
IHttpHandler.cs
IHttpHandlerFactory.cs
IHttpModule.cs
IPrincipalContainer.cs
IRequestCompletedNotifier.cs
ISubscriptionToken.cs
ITlsTokenBindingInfo.cs
IdleTimeoutMonitor.cs
IisTraceListener.cs
ImpersonationContext.cs
ImplicitAsyncPreloadModule.cs
IntSecurity.cs
LegacyAspNetSynchronizationContext.cs
MimeMapping.cs
ModuleConfigurationInfo.cs
ModulesEntry.cs
MultipartContentParser.cs
NativeMethods.cs
NotificationContext.cs
OutputCacheModule.cs
PartitionResolver.cs
PerfCounters.cs
PipelineModuleStepContainer.cs
PreApplicationStartMethodAttribute.cs
ProcessInfo.cs
ProcessModelInfo.cs
ReadEntityBodyMode.cs
RequestNotification.cs
RequestNotificationStatus.cs
RequestQueue.cs
RequestTimeoutManager.cs
RootedObjects.cs
SafeNativeMethods.cs
SiteMap.cs
SiteMapNode.cs
SiteMapNodeCollection.cs
SiteMapProvider.cs
StaticFileHandler.cs
StaticSiteMapProvider.cs
StringResourceManager.cs
System.Web.txt.REMOVED.git-id
TaskAsyncHelper.cs
TaskWrapperAsyncResult.cs
ThreadContext.cs
UnsafeNativeMethods.cs
UnvalidatedRequestValues.cs
UnvalidatedRequestValuesBase.cs
UnvalidatedRequestValuesWrapper.cs
UrlMappingsModule.cs
ValidateStringCallback.cs
VirtualPath.cs
VirtualPathUtility.cs
WebCategoryAttribute.cs
WebPageTraceListener.cs
WebSocketPipeline.cs
WebSocketTransitionState.cs
WebSysDefaultValueAttribute.cs
WebSysDescriptionAttribute.cs
WebSysDisplayNameAttribute.cs
WorkerRequest.cs
XmlSiteMapProvider.cs
cacheexpires.cspp
cacheusage.cspp
httpapplicationstate.cs
httpserverutility.cs
httpstaticobjectscollection.cs
System.Web.ApplicationServices
System.Web.DataVisualization
System.Web.DynamicData
System.Web.Entity
System.Web.Entity.Design
System.Web.Extensions
System.Web.Mobile
System.Web.Routing
System.Web.Services
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.WorkflowServices
System.Xaml.Hosting
System.Xml
System.Xml.Linq
XamlBuildTask
mscorlib
LICENSE.txt
PATENTS.TXT
README.Mono.md
README.md
test-helpers
LICENSE
Makefile
Open.snk
README
ecma.pub
mono.pub
mono.snk
msfinal.pub
reactive.pub
silverlight.pub
winfx.pub
winfx3.pub
docs
errors
ilasm
jay
mcs
nunit24
packages
tests
tools
AUTHORS
COPYING
INSTALL.txt
Makefile
MonoIcon.png
README
ScalableMonoIcon.svg
mkinstalldirs
mk
mono
msvc
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
104 lines
4.9 KiB
C#
104 lines
4.9 KiB
C#
![]() |
//------------------------------------------------------------------------------
|
|||
|
// <copyright file="UnmanagedWebSocketContext.cs" company="Microsoft">
|
|||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|||
|
// </copyright>
|
|||
|
//------------------------------------------------------------------------------
|
|||
|
|
|||
|
namespace System.Web.WebSockets {
|
|||
|
using System;
|
|||
|
using System.Runtime.InteropServices;
|
|||
|
using System.Security;
|
|||
|
using System.Security.Permissions;
|
|||
|
|
|||
|
// Concrete implementation of IUnmanagedWebSocketContext, implemented by IIS8 unmanaged WebSocket module
|
|||
|
// SECURITY NOTE: All parameters are assumed to have been validated by the caller
|
|||
|
|
|||
|
[SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode = true)]
|
|||
|
internal sealed class UnmanagedWebSocketContext : IUnmanagedWebSocketContext {
|
|||
|
|
|||
|
// the 'this' parameter for the unmanaged interface
|
|||
|
private readonly IntPtr _pWebSocketContext;
|
|||
|
|
|||
|
internal UnmanagedWebSocketContext(IntPtr pWebSocketContext) {
|
|||
|
_pWebSocketContext = pWebSocketContext;
|
|||
|
}
|
|||
|
|
|||
|
public int WriteFragment(IntPtr pData, ref int pcbSent, bool fAsync, bool fUtf8Encoded, bool fFinalFragment, IntPtr pfnCompletion, IntPtr pvCompletionContext, out bool pfCompletionExpected) {
|
|||
|
return IIS.MgdWebSocketWriteFragment(_pWebSocketContext, pData, ref pcbSent, fAsync, fUtf8Encoded, fFinalFragment, pfnCompletion, pvCompletionContext, out pfCompletionExpected);
|
|||
|
}
|
|||
|
|
|||
|
public int ReadFragment(IntPtr pData, ref int pcbData, bool fAsync, out bool pfUtf8Encoded, out bool pfFinalFragment, out bool pfConnectionClose, IntPtr pfnCompletion, IntPtr pvCompletionContext, out bool pfCompletionExpected) {
|
|||
|
return IIS.MgdWebSocketReadFragment(_pWebSocketContext, pData, ref pcbData, fAsync, out pfUtf8Encoded, out pfFinalFragment, out pfConnectionClose, pfnCompletion, pvCompletionContext, out pfCompletionExpected);
|
|||
|
}
|
|||
|
|
|||
|
public int SendConnectionClose(bool fAsync, ushort uStatusCode, string szReason, IntPtr pfnCompletion, IntPtr pvCompletionContext, out bool pfCompletionExpected) {
|
|||
|
return IIS.MgdWebSocketSendConnectionClose(_pWebSocketContext, fAsync, uStatusCode, szReason, pfnCompletion, pvCompletionContext, out pfCompletionExpected);
|
|||
|
}
|
|||
|
|
|||
|
public int GetCloseStatus(out ushort pStatusCode, out IntPtr ppszReason, out ushort pcchReason) {
|
|||
|
return IIS.MgdWebSocketGetCloseStatus(_pWebSocketContext, out pStatusCode, out ppszReason, out pcchReason);
|
|||
|
}
|
|||
|
|
|||
|
public void CloseTcpConnection() {
|
|||
|
IIS.MgdWebSocketCloseTcpConnection(_pWebSocketContext);
|
|||
|
}
|
|||
|
|
|||
|
// API documentation for each method can be found in ndp/fx/src/xsp/webengine/mgdexports.cxx.
|
|||
|
[SuppressUnmanagedCodeSecurity]
|
|||
|
private static class IIS {
|
|||
|
private const string _IIS_NATIVE_DLL = ModName.MGDENG_FULL_NAME;
|
|||
|
|
|||
|
// Write a data fragment to the provided IWebSocketContext.
|
|||
|
[DllImport(_IIS_NATIVE_DLL)]
|
|||
|
internal static extern int MgdWebSocketWriteFragment(
|
|||
|
IntPtr pContext,
|
|||
|
IntPtr pData,
|
|||
|
ref int pcbSent,
|
|||
|
bool fAsync,
|
|||
|
bool fUTF8Encoded,
|
|||
|
bool fFinalFragment,
|
|||
|
IntPtr pfnCompletion,
|
|||
|
IntPtr pvCompletionContext,
|
|||
|
out bool pfCompletionExpected);
|
|||
|
|
|||
|
// Reads a data fragment from the provided IWebSocketContext.
|
|||
|
[DllImport(_IIS_NATIVE_DLL)]
|
|||
|
internal static extern int MgdWebSocketReadFragment(
|
|||
|
IntPtr pContext,
|
|||
|
IntPtr pData,
|
|||
|
ref int pcbData,
|
|||
|
bool fAsync,
|
|||
|
out bool pfUTF8Encoded,
|
|||
|
out bool pfFinalFragment,
|
|||
|
out bool pfConnectionClose,
|
|||
|
IntPtr pfnCompletion,
|
|||
|
IntPtr pvCompletionContext,
|
|||
|
out bool pfCompletionExpected);
|
|||
|
|
|||
|
// Sends a CLOSE frame to the provided IWebSocketContext.
|
|||
|
[DllImport(_IIS_NATIVE_DLL)]
|
|||
|
internal static extern int MgdWebSocketSendConnectionClose(
|
|||
|
IntPtr pContext,
|
|||
|
bool fAsync,
|
|||
|
ushort pStatusCode,
|
|||
|
[MarshalAs(UnmanagedType.LPWStr)] string pszReason,
|
|||
|
IntPtr pfnCompletion,
|
|||
|
IntPtr pvCompletionContext,
|
|||
|
out bool pfCompletionExpected);
|
|||
|
|
|||
|
// Gets information on the CLOSE frame sent from the client to the server.
|
|||
|
[DllImport(_IIS_NATIVE_DLL)]
|
|||
|
internal static extern int MgdWebSocketGetCloseStatus(
|
|||
|
IntPtr pContext,
|
|||
|
out ushort pStatusCode,
|
|||
|
out IntPtr ppszReason,
|
|||
|
out ushort pcchReason);
|
|||
|
|
|||
|
// Closes the TCP connection used by the provided IWebSocketContext.
|
|||
|
[DllImport(_IIS_NATIVE_DLL)]
|
|||
|
internal static extern void MgdWebSocketCloseTcpConnection(
|
|||
|
IntPtr pContext);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|