Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature wamp #325

Merged
merged 7 commits into from
Dec 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,10 @@ public async Task NewConnection(WebSocketData data)
}

/// <exclude />
[RoutePrefix("Composite/api/Router")]
public class RouterController : ApiController
{
/// <exclude />
[Route("")]
public HttpResponseMessage Get()
public virtual HttpResponseMessage Get()
{
if (HttpContext.Current.IsWebSocketRequest)
{
Expand Down
5 changes: 0 additions & 5 deletions Composite/Core/WebClient/Services/WampRouter/IRpcService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,5 @@ namespace Composite.Core.WebClient.Services.WampRouter
/// </summary>
public interface IRpcService
{
/// <summary>
/// Basic ping method
/// </summary>
[WampProcedure("ping")]
void Ping();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ namespace Composite.Core.WebClient.Services.WampRouter
/// <summary>
/// This class should be implemented when a publisher is going to be registered on Wamp Router
/// </summary>
/// <typeparam name="T1"></typeparam>
/// <typeparam name="T2"></typeparam>
public interface IWampEventHandler<out T1,out T2>
/// <typeparam name="TObservable"></typeparam>
/// <typeparam name="TResult"></typeparam>
public interface IWampEventHandler<out TObservable,out TResult>
{
/// <summary>
/// Topic uri
Expand All @@ -16,12 +16,12 @@ public interface IWampEventHandler<out T1,out T2>
/// <summary>
/// Observable event
/// </summary>
IObservable<T1> Event { get; }
IObservable<TObservable> Event { get; }

/// <summary>
/// Data to be published from the observable event
/// </summary>
/// <returns></returns>
T2 GetNewData();
TResult GetNewData();
}
}
20 changes: 15 additions & 5 deletions Composite/Core/WebClient/Services/WampRouter/WampRouter.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Net.Http;
using System.Reactive.Subjects;
using System.Web.Http;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using WampSharp.Binding;
Expand All @@ -9,6 +11,12 @@

namespace Composite.Core.WebClient.Services.WampRouter
{
/// <exclude />
[Route("Composite/api/Router")]
public class MyRouterController : AspNetWebsocketTransform.RouterController
{
}

internal class WampRouter
{
private const string DefaultRealmName = "realm";
Expand All @@ -34,19 +42,21 @@ public void RegisterCallee(string realmName, IRpcService instance)
registrationTask.Wait();
}

public void RegisterPublisher<T1, T2>(IWampEventHandler<T1, T2> eventObservable)
public void RegisterPublisher<TObservable, TResult>
(IWampEventHandler<TObservable, TResult> eventObservable)
{
RegisterPublisher(DefaultRealmName, eventObservable);
}

public void RegisterPublisher<T1,T2>(string realmName, IWampEventHandler<T1,T2> eventObservable)
public void RegisterPublisher<TObservable, TResult>
(string realmName, IWampEventHandler<TObservable,TResult> eventObservable)
{
IWampHostedRealm realm = _host.RealmContainer.GetRealmByName(realmName);

ISubject<T2> subject =
realm.Services.GetSubject<T2>(eventObservable.Topic);
ISubject<TResult> subject =
realm.Services.GetSubject<TResult>(eventObservable.Topic);

IObservable<T1> observableEvent = eventObservable.Event;
IObservable<TObservable> observableEvent = eventObservable.Event;

IDisposable disposable =
observableEvent.Subscribe(x =>
Expand Down
15 changes: 8 additions & 7 deletions Composite/Core/WebClient/Services/WampRouter/WampRouterFacade.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Composite.Core.Application;

namespace Composite.Core.WebClient.Services.WampRouter
{
/// <summary>
Expand All @@ -25,7 +23,6 @@ public static bool RegisterCallee(string realmName, IRpcService instance)
/// <summary>
/// Method for registering callee
/// </summary>
/// <param name="realmName"></param>
/// <param name="instance"></param>
/// <returns></returns>
public static bool RegisterCallee(IRpcService instance)
Expand All @@ -42,9 +39,11 @@ public static bool RegisterCallee(IRpcService instance)
/// </summary>
/// <param name="realmName"></param>
/// <param name="eventObservable"></param>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TObservable"></typeparam>
/// <typeparam name="TResult"></typeparam>
/// <returns></returns>
public static bool RegisterPublisher<T1,T2>(string realmName, IWampEventHandler<T1,T2> eventObservable)
public static bool RegisterPublisher<TObservable,TResult>
(string realmName, IWampEventHandler<TObservable, TResult> eventObservable)
{
var wampRouter = ServiceLocator.GetRequiredService<WampRouter>();
if (wampRouter == null)
Expand All @@ -57,9 +56,11 @@ public static bool RegisterPublisher<T1,T2>(string realmName, IWampEventHandler<
/// Method for registering publisher
/// </summary>
/// <param name="eventObservable"></param>
/// <typeparam name="T"></typeparam>
/// <typeparam name="TObservable"></typeparam>
/// <typeparam name="TResult"></typeparam>
/// <returns></returns>
public static bool RegisterPublisher<T1, T2>(IWampEventHandler<T1, T2> eventObservable)
public static bool RegisterPublisher<TObservable,TResult>
(IWampEventHandler<TObservable, TResult> eventObservable)
{
var wampRouter = ServiceLocator.GetRequiredService<WampRouter>();
if (wampRouter == null)
Expand Down
9 changes: 9 additions & 0 deletions Website/ReleaseBuild.Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,13 @@
<system.serviceModel>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<codeBase version="1.2.0.0" href="bin\ExtraDllVersion\System.Collections.Immutable.dll" />
<bindingRedirect oldVersion="0.0.0.0-1.1.20.0" newVersion="1.1.20.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
3 changes: 1 addition & 2 deletions Website/WebSite.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2630,8 +2630,7 @@ if not %25rce%25==1 exit %25rce%25 else exit 0</PreBuildEvent>
</PostBuildEvent>
<PostBuildEvent>if not exist "$(ProjectDir)\bin\ExtraDllVersion" (
md "$(ProjectDir)\bin\ExtraDllVersion"
rem cd "$(SolutionDir)\Packages\System.Collections.Immutable.1.2.0\lib\netstandard1.0"
start /MIN copy "$(SolutionDir)\Packages\System.Collections.Immutable.1.2.0\lib\netstandard1.0\*.dll" "$(ProjectDir)\bin\ExtraDllVersion"
copy "$(ProjectDir)\..\Packages\System.Collections.Immutable.1.2.0\lib\netstandard1.0\*.dll" "$(ProjectDir)\bin\ExtraDllVersion" /y
)</PostBuildEvent>
</PropertyGroup>
</Project>