Skip to content

Commit

Permalink
Version 2.1.1
Browse files Browse the repository at this point in the history
Minor changes
  • Loading branch information
vtortola committed Jun 14, 2014
1 parent 32d6edf commit 767b422
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
</Choose>
<ItemGroup>
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="With_WebSocketFrameHeader.cs" />
<Compile Include="With_WebSocket.cs" />
<Compile Include="With_WebSocketFrameHeaderFlags.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
101 changes: 101 additions & 0 deletions tests/WebSocketListener.UnitTests/With_WebSocketFrameHeader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using vtortola.WebSockets;
using vtortola.WebSockets.Rfc6455;

namespace WebSocketListener.UnitTests
{
[TestClass]
public class With_WebSocketFrameHeader
{
[TestMethod]
public void With_WebSocketFrameHeaderFlags_Can_CreateSmallHeader()
{
var header = WebSocketFrameHeader.Create(101, true, false, WebSocketFrameOption.Text, new WebSocketExtensionFlags());
Byte[] buffer = new Byte[2];
header.ToBytes(buffer, 0);
Assert.AreEqual(129, buffer[0]);
Assert.AreEqual(101, buffer[1]);
}

[TestMethod]
public void With_WebSocketFrameHeaderFlags_Can_CreateMediumHeader()
{
var header = WebSocketFrameHeader.Create(138, true, false, WebSocketFrameOption.Text, new WebSocketExtensionFlags());
Byte[] buffer = new Byte[4];
header.ToBytes(buffer, 0);
Assert.AreEqual(129, buffer[0]);
Assert.AreEqual(126, buffer[1]);
Assert.AreEqual(0, buffer[2]);
Assert.AreEqual(138, buffer[3]);
}

[TestMethod]
public void With_WebSocketFrameHeaderFlags_Can_CreateBigHeader()
{
var header = WebSocketFrameHeader.Create(Int32.MaxValue, true, false, WebSocketFrameOption.Text, new WebSocketExtensionFlags());
Byte[] buffer = new Byte[10];
header.ToBytes(buffer, 0);
Assert.AreEqual(129, buffer[0]);
Assert.AreEqual(127, buffer[1]);
Assert.AreEqual(0, buffer[2]);
Assert.AreEqual(0, buffer[3]);
Assert.AreEqual(0, buffer[4]);
Assert.AreEqual(0, buffer[5]);
Assert.AreEqual(127, buffer[6]);
Assert.AreEqual(255, buffer[7]);
Assert.AreEqual(255, buffer[8]);
Assert.AreEqual(255, buffer[9]);
}

[TestMethod]
public void With_WebSocketFrameHeaderFlags_Can_CreateStartPartialFrameHeader()
{
var header = WebSocketFrameHeader.Create(101, false, false, WebSocketFrameOption.Text, new WebSocketExtensionFlags());
Byte[] buffer = new Byte[2];
header.ToBytes(buffer, 0);
Assert.AreEqual(1, buffer[0]);
Assert.AreEqual(101, buffer[1]);
}

[TestMethod]
public void With_WebSocketFrameHeaderFlags_Can_CreateContinuationPartialFrameHeader()
{
var header = WebSocketFrameHeader.Create(101, false, true, WebSocketFrameOption.Text, new WebSocketExtensionFlags());
Byte[] buffer = new Byte[2];
header.ToBytes(buffer, 0);
Assert.AreEqual(0, buffer[0]);
Assert.AreEqual(101, buffer[1]);
}

[TestMethod]
public void With_WebSocketFrameHeaderFlags_Can_CreateFinalPartialFrameHeader()
{
var header = WebSocketFrameHeader.Create(101, true, true, WebSocketFrameOption.Text, new WebSocketExtensionFlags());
Byte[] buffer = new Byte[2];
header.ToBytes(buffer, 0);
Assert.AreEqual(128, buffer[0]);
Assert.AreEqual(101, buffer[1]);
}

[TestMethod]
public void With_WebSocketFrameHeaderFlags_Can_CreateBinaryFrameHeader()
{
var header = WebSocketFrameHeader.Create(101, true, false, WebSocketFrameOption.Binary, new WebSocketExtensionFlags());
Byte[] buffer = new Byte[2];
header.ToBytes(buffer, 0);
Assert.AreEqual(130, buffer[0]);
Assert.AreEqual(101, buffer[1]);
}

[TestMethod]
public void With_WebSocketFrameHeaderFlags_Can_CreateBinaryFrameHeader_WithExtensions()
{
var header = WebSocketFrameHeader.Create(101, true, false, WebSocketFrameOption.Binary, new WebSocketExtensionFlags() { Rsv1 = true, Rsv2 = true });
Byte[] buffer = new Byte[2];
header.ToBytes(buffer, 0);
Assert.AreEqual(226, buffer[0]);
Assert.AreEqual(101, buffer[1]);
}
}
}
4 changes: 2 additions & 2 deletions vtortola.WebSockets.Deflate/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyVersion("2.1.1.0")]
[assembly: AssemblyFileVersion("2.1.1.0")]
4 changes: 2 additions & 2 deletions vtortola.WebSockets.Rfc6455/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyVersion("2.1.1.0")]
[assembly: AssemblyFileVersion("2.1.1.0")]
4 changes: 2 additions & 2 deletions vtortola.WebSockets.Rfc6455/WebSocketConnectionRfc6455.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ internal WebSocketConnectionRfc6455(Stream clientStream, WebSocketListenerOption
_closeBuffer = new ArraySegment<Byte>(_buffer, 14 + 125 + 125 + 8 + 10 + _options.SendBufferSize + 4, 2);

_pingTimeout = _options.PingTimeout;
_pingInterval = TimeSpan.FromMilliseconds(Math.Min(500, _options.PingTimeout.TotalMilliseconds / 3));
_pingInterval = TimeSpan.FromMilliseconds(Math.Min(500, _options.PingTimeout.TotalMilliseconds / 2));
}
private void StartPing()
{
Expand Down Expand Up @@ -304,7 +304,7 @@ private async Task PingAsync()
var now = DateTime.Now;

if (_lastPong.Add(_pingTimeout) < now)
Close(WebSocketCloseReasons.NormalClose);
Close(WebSocketCloseReasons.GoingAway);
else
{
((UInt64)now.Ticks).ToBytes(_pingBuffer.Array, _pingBuffer.Offset);
Expand Down
4 changes: 2 additions & 2 deletions vtortola.WebSockets/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyVersion("2.1.1.0")]
[assembly: AssemblyFileVersion("2.1.1.0")]

0 comments on commit 767b422

Please sign in to comment.