-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Elad Zelingher
committed
Oct 9, 2014
1 parent
ba55d49
commit 0ae214d
Showing
13 changed files
with
714 additions
and
17 deletions.
There are no files selected for viewing
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,22 @@ | ||
<?xml version="1.0"?> | ||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd"> | ||
<metadata> | ||
<version>$version$</version> | ||
<authors>CodeSharp</authors> | ||
<owners /> | ||
<dependencies> | ||
<dependency id="WampSharp.Default" version="[$version$]" /> | ||
<dependency id="vtortola.WebSocketListener" version="[2.1.1.0]" /> | ||
</dependencies> | ||
<id>WampSharp.Vtortola</id> | ||
<title>WampSharp Vtortola support</title> | ||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | ||
<description>Vtortola transport for WampSharp</description> | ||
<projectUrl>https:/Code-Sharp/WampSharp/</projectUrl> | ||
<tags>websockets wampws rpc pubsub vtortola wampv2</tags> | ||
</metadata> | ||
<files> | ||
<file src="bin\net45\WampSharp.Vtortola.dll" target="lib\net45\WampSharp.Vtortola.dll" /> | ||
<file src="bin\net45\WampSharp.Vtortola.xml" target="lib\net45\WampSharp.Vtortola.xml" /> | ||
</files> | ||
</package> |
111 changes: 111 additions & 0 deletions
111
src/mono/Extensions/WampSharp.Vtortola/WampSharp.Vtortola.csproj
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,111 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{DE13BC69-B822-45EA-846F-DDEF66D34BD9}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>WampSharp.Vtortola</RootNamespace> | ||
<AssemblyName>WampSharp.Vtortola</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> | ||
<RestorePackages>true</RestorePackages> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<DocumentationFile>bin\Debug\WampSharp.Vtortola.XML</DocumentationFile> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Castle.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\..\packages\Castle.Core.3.3.1\lib\net45\Castle.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Reactive.Core"> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System.Reactive.Interfaces"> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System.Reactive.Linq"> | ||
<Private>True</Private> | ||
</Reference> | ||
<Reference Include="System.Threading.Tasks.Dataflow, Version=4.5.9.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL"> | ||
<Private>True</Private> | ||
<HintPath>..\..\packages\Microsoft.Tpl.Dataflow.4.5.9\lib\net45\System.Threading.Tasks.Dataflow.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="vtortola.WebSockets"> | ||
<HintPath>..\..\packages\vtortola.WebSocketListener.2.1.1.0\lib\net45\vtortola.WebSockets.dll</HintPath> | ||
</Reference> | ||
<Reference Include="vtortola.WebSockets.Deflate"> | ||
<HintPath>..\..\packages\vtortola.WebSocketListener.2.1.1.0\lib\net45\vtortola.WebSockets.Deflate.dll</HintPath> | ||
</Reference> | ||
<Reference Include="vtortola.WebSockets.Rfc6455"> | ||
<HintPath>..\..\packages\vtortola.WebSocketListener.2.1.1.0\lib\net45\vtortola.WebSockets.Rfc6455.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="..\..\..\net45\Extensions\WampSharp.Vtortola\Properties\AssemblyInfo.cs"> | ||
<Link>Properties\AssemblyInfo.cs</Link> | ||
</Compile> | ||
<Compile Include="..\..\..\net45\Extensions\WampSharp.Vtortola\VtortolaWampBinaryConnection.cs"> | ||
<Link>VtortolaWampBinaryConnection.cs</Link> | ||
</Compile> | ||
<Compile Include="..\..\..\net45\Extensions\WampSharp.Vtortola\VtortolaWampConnection.cs"> | ||
<Link>VtortolaWampConnection.cs</Link> | ||
</Compile> | ||
<Compile Include="..\..\..\net45\Extensions\WampSharp.Vtortola\VtortolaWampTextConnection.cs"> | ||
<Link>VtortolaWampTextConnection.cs</Link> | ||
</Compile> | ||
<Compile Include="..\..\..\net45\Extensions\WampSharp.Vtortola\VtortolaWebSocketTransport.cs"> | ||
<Link>VtortolaWebSocketTransport.cs</Link> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="packages.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\WampSharp\WampSharp.csproj"> | ||
<Project>{653A76DC-00D7-4EFF-A25E-2FA10C5C927D}</Project> | ||
<Name>WampSharp</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" /> | ||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
<PropertyGroup> | ||
<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> | ||
</PropertyGroup> | ||
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /> | ||
</Target> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="Castle.Core" version="3.3.1" targetFramework="net45" /> | ||
<package id="Microsoft.Tpl.Dataflow" version="4.5.9" targetFramework="net45" /> | ||
<package id="vtortola.WebSocketListener" version="2.1.1.0" targetFramework="net45" /> | ||
</packages> |
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
36 changes: 36 additions & 0 deletions
36
src/net45/Extensions/WampSharp.Vtortola/Properties/AssemblyInfo.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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("WampSharp.Vtortola")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("WampSharp.Vtortola")] | ||
[assembly: AssemblyCopyright("Copyright © 2014")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("c15d9995-9bd4-491a-837a-c97f97b4eaec")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// 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("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
39 changes: 39 additions & 0 deletions
39
src/net45/Extensions/WampSharp.Vtortola/VtortolaWampBinaryConnection.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,39 @@ | ||
using System.IO; | ||
using vtortola.WebSockets; | ||
using WampSharp.Core.Message; | ||
using WampSharp.V2.Binding; | ||
|
||
namespace WampSharp.Vtortola | ||
{ | ||
internal class VtortolaWampBinaryConnection<TMessage> : VtortolaWampConnection<TMessage> | ||
{ | ||
private readonly IWampBinaryBinding<TMessage> mBinding; | ||
|
||
public VtortolaWampBinaryConnection(WebSocket connection, IWampBinaryBinding<TMessage> binding) : | ||
base(connection) | ||
{ | ||
mBinding = binding; | ||
} | ||
|
||
protected override WampMessage<TMessage> ParseMessage(WebSocketMessageReadStream readStream) | ||
{ | ||
using (MemoryStream memoryStream = new MemoryStream()) | ||
{ | ||
readStream.CopyTo(memoryStream); | ||
byte[] bytes = memoryStream.ToArray(); | ||
WampMessage<TMessage> result = mBinding.Parse(bytes); | ||
return result; | ||
} | ||
} | ||
|
||
public override void Send(WampMessage<TMessage> message) | ||
{ | ||
using (WebSocketMessageWriteStream stream = | ||
mWebsocket.CreateMessageWriter(WebSocketMessageType.Binary)) | ||
{ | ||
byte[] raw = mBinding.Format(message); | ||
stream.Write(raw, 0, raw.Length); | ||
} | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/net45/Extensions/WampSharp.Vtortola/VtortolaWampConnection.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,77 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using vtortola.WebSockets; | ||
using WampSharp.Core.Listener; | ||
using WampSharp.Core.Message; | ||
|
||
namespace WampSharp.Vtortola | ||
{ | ||
internal abstract class VtortolaWampConnection<TMessage> : IWampConnection<TMessage> | ||
{ | ||
protected readonly WebSocket mWebsocket; | ||
|
||
public VtortolaWampConnection(WebSocket websocket) | ||
{ | ||
mWebsocket = websocket; | ||
} | ||
|
||
public async Task HandleWebSocketAsync() | ||
{ | ||
try | ||
{ | ||
if (ConnectionOpen != null) | ||
{ | ||
ConnectionOpen(this, EventArgs.Empty); | ||
} | ||
|
||
while (mWebsocket.IsConnected) | ||
{ | ||
WebSocketMessageReadStream message = | ||
await mWebsocket.ReadMessageAsync(CancellationToken.None) | ||
.ConfigureAwait(false); | ||
|
||
if (message != null) | ||
{ | ||
using (message) | ||
{ | ||
if (MessageArrived != null) | ||
{ | ||
WampMessage<TMessage> parsed = ParseMessage(message); | ||
|
||
MessageArrived(this, | ||
new WampMessageArrivedEventArgs<TMessage>(parsed)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
if (ConnectionClosed != null) | ||
{ | ||
ConnectionClosed(this, EventArgs.Empty); | ||
} | ||
} | ||
catch (Exception ex) | ||
{ | ||
if (ConnectionError != null) | ||
{ | ||
ConnectionError(this, new WampConnectionErrorEventArgs(ex)); | ||
} | ||
} | ||
} | ||
|
||
protected abstract WampMessage<TMessage> ParseMessage(WebSocketMessageReadStream readStream); | ||
|
||
public void Dispose() | ||
{ | ||
mWebsocket.Dispose(); | ||
} | ||
|
||
public abstract void Send(WampMessage<TMessage> message); | ||
|
||
public event EventHandler ConnectionOpen; | ||
public event EventHandler<WampMessageArrivedEventArgs<TMessage>> MessageArrived; | ||
public event EventHandler ConnectionClosed; | ||
public event EventHandler<WampConnectionErrorEventArgs> ConnectionError; | ||
} | ||
} |
Oops, something went wrong.