Created
July 7, 2017 01:44
-
-
Save xplicit/002d99b07513afa07e5f3e36d499e5f2 to your computer and use it in GitHub Desktop.
ServerEvents Host
This file contains hidden or 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
using System.Threading; | |
using Funq; | |
using ServiceStack; | |
public class AppHost : AppSelfHostBase | |
{ | |
public static ManualResetEvent ShouldQuit = new ManualResetEvent(false); | |
public AppHost() | |
: base("SelfHost1", typeof(MyServices).Assembly) | |
{ | |
} | |
public override void Configure(Container container) | |
{ | |
Plugins.Add(new ServerEventsFeature()); | |
} | |
} | |
[Route("/stop")] | |
public class Stop : IReturnVoid | |
{ | |
} | |
[Route("/hello/{Name}")] | |
public class Hello : IReturn<HelloResponse> | |
{ | |
public string Name { get; set; } | |
} | |
public class HelloResponse | |
{ | |
public string Result { get; set; } | |
} | |
public class MyServices : Service | |
{ | |
public object Any(Hello request) => new HelloResponse { Result = "Hello, {0}!".Fmt(request.Name) }; | |
public void Any(Stop request) => AppHost.ShouldQuit.Set(); | |
} | |
var host = new AppHost().Init().Start("http://*:9013/"); | |
AppHost.ShouldQuit.WaitOne(); |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<packages> | |
<package id="ServiceStack.Text" version="4.5.12" targetFramework="net45" /> | |
<package id="ServiceStack.Client" version="4.5.12" targetFramework="net45" /> | |
<package id="ServiceStack.Interfaces" version="4.5.12" targetFramework="net45" /> | |
<package id="ServiceStack" version="4.5.12" targetFramework="net45" /> | |
</packages> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment