-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made some changes to better abstract BufferTextWriter.
- Added BinaryTextWriter which is a buffer text writer that supports writing array segments. - Updated tests. - Added tests for forever frame encoding full messages.
- Loading branch information
Showing
9 changed files
with
88 additions
and
25 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/Microsoft.AspNet.SignalR.Core/Infrastructure/BinaryTextWriter.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,34 @@ | ||
using System; | ||
using Microsoft.AspNet.SignalR.Hosting; | ||
|
||
namespace Microsoft.AspNet.SignalR.Infrastructure | ||
{ | ||
/// <summary> | ||
/// A buffering text writer that supports writing binary directly as well | ||
/// </summary> | ||
internal unsafe class BinaryTextWriter : BufferTextWriter, IBinaryWriter | ||
{ | ||
public BinaryTextWriter(IResponse response) : | ||
base((data, state) => ((IResponse)state).Write(data), response, reuseBuffers: true, bufferSize: 128) | ||
{ | ||
|
||
} | ||
|
||
public BinaryTextWriter(IWebSocket socket) : | ||
base((data, state) => ((IWebSocket)state).SendChunk(data), socket, reuseBuffers: false, bufferSize: 1024) | ||
{ | ||
|
||
} | ||
|
||
|
||
public BinaryTextWriter(Action<ArraySegment<byte>, object> write, object state, bool reuseBuffers, int bufferSize) : | ||
base(write, state, reuseBuffers, bufferSize) | ||
{ | ||
} | ||
|
||
public void Write(ArraySegment<byte> data) | ||
{ | ||
Writer.Write(data); | ||
} | ||
} | ||
} |
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
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