Skip to content

Commit 0ae214d

Browse files
author
Elad Zelingher
committed
Add Vtortola support
1 parent ba55d49 commit 0ae214d

13 files changed

+714
-17
lines changed

NuGet/WampSharp.Vtortola.nuspec

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
3+
<metadata>
4+
<version>$version$</version>
5+
<authors>CodeSharp</authors>
6+
<owners />
7+
<dependencies>
8+
<dependency id="WampSharp.Default" version="[$version$]" />
9+
<dependency id="vtortola.WebSocketListener" version="[2.1.1.0]" />
10+
</dependencies>
11+
<id>WampSharp.Vtortola</id>
12+
<title>WampSharp Vtortola support</title>
13+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
14+
<description>Vtortola transport for WampSharp</description>
15+
<projectUrl>https://github.com/Code-Sharp/WampSharp/</projectUrl>
16+
<tags>websockets wampws rpc pubsub vtortola wampv2</tags>
17+
</metadata>
18+
<files>
19+
<file src="bin\net45\WampSharp.Vtortola.dll" target="lib\net45\WampSharp.Vtortola.dll" />
20+
<file src="bin\net45\WampSharp.Vtortola.xml" target="lib\net45\WampSharp.Vtortola.xml" />
21+
</files>
22+
</package>
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{DE13BC69-B822-45EA-846F-DDEF66D34BD9}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>WampSharp.Vtortola</RootNamespace>
11+
<AssemblyName>WampSharp.Vtortola</AssemblyName>
12+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
15+
<RestorePackages>true</RestorePackages>
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
<DocumentationFile>bin\Debug\WampSharp.Vtortola.XML</DocumentationFile>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Castle.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
37+
<SpecificVersion>False</SpecificVersion>
38+
<HintPath>..\..\packages\Castle.Core.3.3.1\lib\net45\Castle.Core.dll</HintPath>
39+
</Reference>
40+
<Reference Include="System" />
41+
<Reference Include="System.Core" />
42+
<Reference Include="System.Reactive.Core">
43+
<Private>True</Private>
44+
</Reference>
45+
<Reference Include="System.Reactive.Interfaces">
46+
<Private>True</Private>
47+
</Reference>
48+
<Reference Include="System.Reactive.Linq">
49+
<Private>True</Private>
50+
</Reference>
51+
<Reference Include="System.Threading.Tasks.Dataflow, Version=4.5.9.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
52+
<Private>True</Private>
53+
<HintPath>..\..\packages\Microsoft.Tpl.Dataflow.4.5.9\lib\net45\System.Threading.Tasks.Dataflow.dll</HintPath>
54+
</Reference>
55+
<Reference Include="System.Xml.Linq" />
56+
<Reference Include="System.Data.DataSetExtensions" />
57+
<Reference Include="Microsoft.CSharp" />
58+
<Reference Include="System.Data" />
59+
<Reference Include="System.Xml" />
60+
<Reference Include="vtortola.WebSockets">
61+
<HintPath>..\..\packages\vtortola.WebSocketListener.2.1.1.0\lib\net45\vtortola.WebSockets.dll</HintPath>
62+
</Reference>
63+
<Reference Include="vtortola.WebSockets.Deflate">
64+
<HintPath>..\..\packages\vtortola.WebSocketListener.2.1.1.0\lib\net45\vtortola.WebSockets.Deflate.dll</HintPath>
65+
</Reference>
66+
<Reference Include="vtortola.WebSockets.Rfc6455">
67+
<HintPath>..\..\packages\vtortola.WebSocketListener.2.1.1.0\lib\net45\vtortola.WebSockets.Rfc6455.dll</HintPath>
68+
</Reference>
69+
</ItemGroup>
70+
<ItemGroup>
71+
<Compile Include="..\..\..\net45\Extensions\WampSharp.Vtortola\Properties\AssemblyInfo.cs">
72+
<Link>Properties\AssemblyInfo.cs</Link>
73+
</Compile>
74+
<Compile Include="..\..\..\net45\Extensions\WampSharp.Vtortola\VtortolaWampBinaryConnection.cs">
75+
<Link>VtortolaWampBinaryConnection.cs</Link>
76+
</Compile>
77+
<Compile Include="..\..\..\net45\Extensions\WampSharp.Vtortola\VtortolaWampConnection.cs">
78+
<Link>VtortolaWampConnection.cs</Link>
79+
</Compile>
80+
<Compile Include="..\..\..\net45\Extensions\WampSharp.Vtortola\VtortolaWampTextConnection.cs">
81+
<Link>VtortolaWampTextConnection.cs</Link>
82+
</Compile>
83+
<Compile Include="..\..\..\net45\Extensions\WampSharp.Vtortola\VtortolaWebSocketTransport.cs">
84+
<Link>VtortolaWebSocketTransport.cs</Link>
85+
</Compile>
86+
</ItemGroup>
87+
<ItemGroup>
88+
<None Include="packages.config" />
89+
</ItemGroup>
90+
<ItemGroup>
91+
<ProjectReference Include="..\..\WampSharp\WampSharp.csproj">
92+
<Project>{653A76DC-00D7-4EFF-A25E-2FA10C5C927D}</Project>
93+
<Name>WampSharp</Name>
94+
</ProjectReference>
95+
</ItemGroup>
96+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
97+
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
98+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
99+
<PropertyGroup>
100+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
101+
</PropertyGroup>
102+
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
103+
</Target>
104+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
105+
Other similar extension points exist, see Microsoft.Common.targets.
106+
<Target Name="BeforeBuild">
107+
</Target>
108+
<Target Name="AfterBuild">
109+
</Target>
110+
-->
111+
</Project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Castle.Core" version="3.3.1" targetFramework="net45" />
4+
<package id="Microsoft.Tpl.Dataflow" version="4.5.9" targetFramework="net45" />
5+
<package id="vtortola.WebSocketListener" version="2.1.1.0" targetFramework="net45" />
6+
</packages>

src/mono/WampSharpMono.sln

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2012
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.30723.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
46
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp", "WampSharp\WampSharp.csproj", "{653A76DC-00D7-4EFF-A25E-2FA10C5C927D}"
57
EndProject
68
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Default", "WampSharp.Default\WampSharp.Default.csproj", "{6AB75291-D296-457E-88A3-B41B16A1A247}"
@@ -41,6 +43,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Samples.Caller",
4143
EndProject
4244
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Samples.Publisher", "Samples\WAMP2\WampSharp.Samples.Publisher\WampSharp.Samples.Publisher.csproj", "{E924BD74-041F-4F3A-8041-FC7F8827728A}"
4345
EndProject
46+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Vtortola", "Extensions\WampSharp.Vtortola\WampSharp.Vtortola.csproj", "{DE13BC69-B822-45EA-846F-DDEF66D34BD9}"
47+
EndProject
4448
Global
4549
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4650
Debug|Any CPU = Debug|Any CPU
@@ -107,6 +111,10 @@ Global
107111
{E924BD74-041F-4F3A-8041-FC7F8827728A}.Debug|Any CPU.Build.0 = Debug|Any CPU
108112
{E924BD74-041F-4F3A-8041-FC7F8827728A}.Release|Any CPU.ActiveCfg = Release|Any CPU
109113
{E924BD74-041F-4F3A-8041-FC7F8827728A}.Release|Any CPU.Build.0 = Release|Any CPU
114+
{DE13BC69-B822-45EA-846F-DDEF66D34BD9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
115+
{DE13BC69-B822-45EA-846F-DDEF66D34BD9}.Debug|Any CPU.Build.0 = Debug|Any CPU
116+
{DE13BC69-B822-45EA-846F-DDEF66D34BD9}.Release|Any CPU.ActiveCfg = Release|Any CPU
117+
{DE13BC69-B822-45EA-846F-DDEF66D34BD9}.Release|Any CPU.Build.0 = Release|Any CPU
110118
EndGlobalSection
111119
GlobalSection(SolutionProperties) = preSolution
112120
HideSolutionNode = FALSE
@@ -117,15 +125,16 @@ Global
117125
{AD5C9AA6-6810-488E-9EDD-FCC945AAD627} = {10B51C05-30BC-412A-BFFB-8C2C02753528}
118126
{2128E477-97B6-4224-A8A9-789F79514B41} = {10B51C05-30BC-412A-BFFB-8C2C02753528}
119127
{0A431511-B51D-42A2-AE0F-DEFCDB9FCE77} = {10B51C05-30BC-412A-BFFB-8C2C02753528}
128+
{7D74C7E0-3F4E-4C60-BC75-C5086706CF7F} = {AF224856-8194-4CA0-92D9-03926B743987}
129+
{678473BD-87FC-4788-A444-4ABF45FDCFEC} = {FA4B348E-3BBD-4F98-B429-891376EBA17E}
130+
{D3FB3310-A761-45B5-AC4B-78FE90C2829C} = {D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E}
131+
{710B61C1-E7E0-4D8F-BF39-F82086D610ED} = {D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E}
132+
{F5B01D7B-14C3-419C-9887-C0A24FF2DE59} = {FA4B348E-3BBD-4F98-B429-891376EBA17E}
120133
{6AD8C6F1-05AE-4826-BE27-BF54C73D6159} = {10B51C05-30BC-412A-BFFB-8C2C02753528}
121134
{32A38656-5BAF-4D80-9780-95C3B594DA3F} = {10B51C05-30BC-412A-BFFB-8C2C02753528}
122-
{7D74C7E0-3F4E-4C60-BC75-C5086706CF7F} = {AF224856-8194-4CA0-92D9-03926B743987}
123135
{0EB744B6-235C-4460-B25C-EBC966201C26} = {AF224856-8194-4CA0-92D9-03926B743987}
124136
{7434FFFF-F5E5-48DF-9544-19131885FA4E} = {AF224856-8194-4CA0-92D9-03926B743987}
125137
{E924BD74-041F-4F3A-8041-FC7F8827728A} = {AF224856-8194-4CA0-92D9-03926B743987}
126-
{D3FB3310-A761-45B5-AC4B-78FE90C2829C} = {D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E}
127-
{710B61C1-E7E0-4D8F-BF39-F82086D610ED} = {D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E}
128-
{678473BD-87FC-4788-A444-4ABF45FDCFEC} = {FA4B348E-3BBD-4F98-B429-891376EBA17E}
129-
{F5B01D7B-14C3-419C-9887-C0A24FF2DE59} = {FA4B348E-3BBD-4F98-B429-891376EBA17E}
138+
{DE13BC69-B822-45EA-846F-DDEF66D34BD9} = {FA4B348E-3BBD-4F98-B429-891376EBA17E}
130139
EndGlobalSection
131140
EndGlobal

src/net40/WampSharpFw4.sln

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 2012
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.30723.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
46
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp", "WampSharp\WampSharp.csproj", "{653A76DC-00D7-4EFF-A25E-2FA10C5C927D}"
57
EndProject
68
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WampSharp.Default", "WampSharp.Default\WampSharp.Default.csproj", "{6AB75291-D296-457E-88A3-B41B16A1A247}"
@@ -111,14 +113,14 @@ Global
111113
{AD5C9AA6-6810-488E-9EDD-FCC945AAD627} = {10B51C05-30BC-412A-BFFB-8C2C02753528}
112114
{2128E477-97B6-4224-A8A9-789F79514B41} = {10B51C05-30BC-412A-BFFB-8C2C02753528}
113115
{0A431511-B51D-42A2-AE0F-DEFCDB9FCE77} = {10B51C05-30BC-412A-BFFB-8C2C02753528}
116+
{7D74C7E0-3F4E-4C60-BC75-C5086706CF7F} = {AF224856-8194-4CA0-92D9-03926B743987}
117+
{678473BD-87FC-4788-A444-4ABF45FDCFEC} = {FA4B348E-3BBD-4F98-B429-891376EBA17E}
118+
{D3FB3310-A761-45B5-AC4B-78FE90C2829C} = {D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E}
119+
{710B61C1-E7E0-4D8F-BF39-F82086D610ED} = {D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E}
114120
{6AD8C6F1-05AE-4826-BE27-BF54C73D6159} = {10B51C05-30BC-412A-BFFB-8C2C02753528}
115121
{32A38656-5BAF-4D80-9780-95C3B594DA3F} = {10B51C05-30BC-412A-BFFB-8C2C02753528}
116-
{7D74C7E0-3F4E-4C60-BC75-C5086706CF7F} = {AF224856-8194-4CA0-92D9-03926B743987}
117122
{0EB744B6-235C-4460-B25C-EBC966201C26} = {AF224856-8194-4CA0-92D9-03926B743987}
118123
{7434FFFF-F5E5-48DF-9544-19131885FA4E} = {AF224856-8194-4CA0-92D9-03926B743987}
119124
{E924BD74-041F-4F3A-8041-FC7F8827728A} = {AF224856-8194-4CA0-92D9-03926B743987}
120-
{D3FB3310-A761-45B5-AC4B-78FE90C2829C} = {D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E}
121-
{710B61C1-E7E0-4D8F-BF39-F82086D610ED} = {D07452C1-0C0A-45C3-8A1B-33BD8FF93C5E}
122-
{678473BD-87FC-4788-A444-4ABF45FDCFEC} = {FA4B348E-3BBD-4F98-B429-891376EBA17E}
123125
EndGlobalSection
124126
EndGlobal
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("WampSharp.Vtortola")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("WampSharp.Vtortola")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("c15d9995-9bd4-491a-837a-c97f97b4eaec")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.IO;
2+
using vtortola.WebSockets;
3+
using WampSharp.Core.Message;
4+
using WampSharp.V2.Binding;
5+
6+
namespace WampSharp.Vtortola
7+
{
8+
internal class VtortolaWampBinaryConnection<TMessage> : VtortolaWampConnection<TMessage>
9+
{
10+
private readonly IWampBinaryBinding<TMessage> mBinding;
11+
12+
public VtortolaWampBinaryConnection(WebSocket connection, IWampBinaryBinding<TMessage> binding) :
13+
base(connection)
14+
{
15+
mBinding = binding;
16+
}
17+
18+
protected override WampMessage<TMessage> ParseMessage(WebSocketMessageReadStream readStream)
19+
{
20+
using (MemoryStream memoryStream = new MemoryStream())
21+
{
22+
readStream.CopyTo(memoryStream);
23+
byte[] bytes = memoryStream.ToArray();
24+
WampMessage<TMessage> result = mBinding.Parse(bytes);
25+
return result;
26+
}
27+
}
28+
29+
public override void Send(WampMessage<TMessage> message)
30+
{
31+
using (WebSocketMessageWriteStream stream =
32+
mWebsocket.CreateMessageWriter(WebSocketMessageType.Binary))
33+
{
34+
byte[] raw = mBinding.Format(message);
35+
stream.Write(raw, 0, raw.Length);
36+
}
37+
}
38+
}
39+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
using vtortola.WebSockets;
5+
using WampSharp.Core.Listener;
6+
using WampSharp.Core.Message;
7+
8+
namespace WampSharp.Vtortola
9+
{
10+
internal abstract class VtortolaWampConnection<TMessage> : IWampConnection<TMessage>
11+
{
12+
protected readonly WebSocket mWebsocket;
13+
14+
public VtortolaWampConnection(WebSocket websocket)
15+
{
16+
mWebsocket = websocket;
17+
}
18+
19+
public async Task HandleWebSocketAsync()
20+
{
21+
try
22+
{
23+
if (ConnectionOpen != null)
24+
{
25+
ConnectionOpen(this, EventArgs.Empty);
26+
}
27+
28+
while (mWebsocket.IsConnected)
29+
{
30+
WebSocketMessageReadStream message =
31+
await mWebsocket.ReadMessageAsync(CancellationToken.None)
32+
.ConfigureAwait(false);
33+
34+
if (message != null)
35+
{
36+
using (message)
37+
{
38+
if (MessageArrived != null)
39+
{
40+
WampMessage<TMessage> parsed = ParseMessage(message);
41+
42+
MessageArrived(this,
43+
new WampMessageArrivedEventArgs<TMessage>(parsed));
44+
}
45+
}
46+
}
47+
}
48+
49+
if (ConnectionClosed != null)
50+
{
51+
ConnectionClosed(this, EventArgs.Empty);
52+
}
53+
}
54+
catch (Exception ex)
55+
{
56+
if (ConnectionError != null)
57+
{
58+
ConnectionError(this, new WampConnectionErrorEventArgs(ex));
59+
}
60+
}
61+
}
62+
63+
protected abstract WampMessage<TMessage> ParseMessage(WebSocketMessageReadStream readStream);
64+
65+
public void Dispose()
66+
{
67+
mWebsocket.Dispose();
68+
}
69+
70+
public abstract void Send(WampMessage<TMessage> message);
71+
72+
public event EventHandler ConnectionOpen;
73+
public event EventHandler<WampMessageArrivedEventArgs<TMessage>> MessageArrived;
74+
public event EventHandler ConnectionClosed;
75+
public event EventHandler<WampConnectionErrorEventArgs> ConnectionError;
76+
}
77+
}

0 commit comments

Comments
 (0)