Hi John
So, lets see if I can explain this in a proper way.
1: Self hosted
Lets say that you would like to host xsockets stand-alone. This could be anything from hosting it in a windows service, console application or Azure etc...
All you need to do to fire up XSockets the is to get the IXSocketServerContainer from the plugin framework and then start it.
Like this.
using XSockets.Core.Common.Socket;
using XSockets.Plugin.Framework;
using (var container = Composable.GetExport<IXSocketServerContainer>())
{
container.Start();
Console.ReadLine();
}
2: Hosted in website
Normally our users do not host XSockets inside of a website/webapp since the browser is just one of the clients that they connect to XSockets.
But, if you would like to host XSockets inside the web you have two options. One is to start xsockets as usual, but inside of the web... The other to let Owin host xsockets.
This will cover the hosting outside of owin.
Pre-Req: Install-Package XSockets
using System.Web;
using XSockets.Core.Common.Socket;
[assembly: PreApplicationStartMethod(typeof(HitCounter.Startup), "Start")]
namespace HitCounter
{
public static class Startup
{
private static IXSocketServerContainer container;
public static void Start()
{
container = XSockets.Plugin.Framework.Composable.GetExport<IXSocketServerContainer>();
container.Start();
}
}
}
There is a template for this, so just choose Add->New Item->XSockets 4->XSockets.Web.Bootstrapper
3: Hosted in Owin
You can host XSockets in Owin (stand alone) or in Owin inside of a webapp...
This will cover the hosting in owin in your webapp.
Pre-Req: Install-Package XSockets.Owin.Host
In the Owin Startup class you just add the line app.UseXSockets(); like so...
using Microsoft.Owin;
using Owin;
using XSockets.Owin.Host;
[assembly: OwinStartup(typeof(HitCounter.Startup))]
namespace HitCounter
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.UseXSockets();
}
}
}
___________________________________
The samples above is taken from the github XSockets Virtual Academy.
https://github.com/XSockets/XVAIn there you can see that almost all the samples has one AnyOS folder and one Win8+ folder.
The difference is that the Win8+ ones uses Owin, and the other uses XSockets stand alone.
When you use owin you will connect to the same port as the web...
If you self host the default startup port id 4502, but you can change that in a number of ways.
You can ofcourse also host on Azure as mentioned, or anywhere that has .NET 4+ or the Mono equivalent.
Regards
Uffe