forked from JeffreySu/WeiXinMPSDK
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Squashed 'src/Senparc.WebSocket/' changes from 7304f4f68..c1a02d9d8
c1a02d9d8 更新.NET 4.5项目版本号 67432b37c Merge branch 'Developer' of https://github.com/JeffreySu/WeiXinMPSDK into Developer efd069c2d 升级WebSocket的Newtonsoft.Json版本 477ea842c modify 7965cc316 WebSocket 0.3.4 升级Newtonsoft.Json版本 4a53f15cb WebSocket 0.3.4 升级Newtonsoft.Json版本 (编译通过) 9d68c67a9 修改 aa75380a3 升级Senparc.WebSocket的NewtonSoft.Json引用(编译未通过) c1a0ed5a4 升级第三方Nuget包 938a32cb7 发布Nuget新版本 422fa8e4b 整理csproj项目文件和解决方案,VS2017对全版本可通过编译 519957d76 modify e1d26d478 继续合并Developer_FullVersion befebfe6b 成功从Developer_FullVersion分支合并(.NET 4.5 Sample跑通) 64a5973c0 成功从Developer_FullVersion分支合并(.NET 4.5 Sample跑通) 2064b430d 发布新版本Nuget 579eeae20 发布新版本Nuget c86e0ed43 合并Developer分支最新代码 112171cec 发布Nuget 9d8e45873 修改WebSocket 0f35df501 合并Developer分支代码,解决冲突 6a4173e29 增加发布版本号 f327d7946 modify e76263b46 merge from Developer branch 0bae74d58 重命名csproj bff2af9b5 更改旧版本项目文件名称 8c1ced68d 修改WebSocket f726edb4c 调整WebSocket目录 297631e7e 添加原始csproj文件的条件编译 179a5ebd1 移除net461版本(MvcExtension的Core版本有保留) JeffreySu#535 b769f97e3 完成WebSocket移植 f1d58fbc8 .NET Core WebSocket移植成功 JeffreySu#535 5589124ff .NET Core WebSocket移植成功 6cbb67f4e 添加CoreWebsocket项目(临时) git-subtree-dir: src/Senparc.WebSocket git-subtree-split: c1a02d9d8648df5ae49e250ee943be937cb2f23e
- Loading branch information
Showing
16 changed files
with
309 additions
and
266 deletions.
There are no files selected for viewing
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
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
58 changes: 58 additions & 0 deletions
58
src/Senparc.WebSocket/Senparc.WebSocket/Routes/WebSocketHandler/WebSocketHandler_Core.cs
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,58 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using System.Net.WebSockets; | ||
using System.Threading.Tasks; | ||
using System.Threading; | ||
|
||
#if NET45 | ||
|
||
#else | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Http.Features; | ||
using Microsoft.AspNetCore.Routing; | ||
using Microsoft.AspNetCore.WebSockets; | ||
#endif | ||
|
||
|
||
namespace Senparc.WebSocket | ||
{ | ||
|
||
#if !NET45 | ||
public partial class WebSocketHandler | ||
{ | ||
public const int BufferSize = 4096; | ||
System.Net.WebSockets.WebSocket _socket; | ||
|
||
WebSocketHandler(System.Net.WebSockets.WebSocket socket) | ||
{ | ||
this._socket = socket; | ||
} | ||
|
||
async Task EchoLoop() | ||
{ | ||
await HandleMessage(_socket); | ||
} | ||
|
||
static async Task Acceptor(HttpContext hc, Func<Task> n) | ||
{ | ||
if (!hc.WebSockets.IsWebSocketRequest) | ||
return; | ||
var socket = await hc.WebSockets.AcceptWebSocketAsync(); | ||
var h = new WebSocketHandler(socket); | ||
await h.EchoLoop(); | ||
} | ||
/// <summary> | ||
/// branches the request pipeline for this SocketHandler usage | ||
/// </summary> | ||
/// <param name="app"></param> | ||
public static void Map(IApplicationBuilder app) | ||
{ | ||
app.UseWebSockets(); | ||
app.Use(WebSocketHandler.Acceptor); | ||
} | ||
} | ||
#endif | ||
} |
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
Oops, something went wrong.