Skip to content

Instantly share code, notes, and snippets.

View XSockets's full-sized avatar

We Are Real Time XSockets

View GitHub Profile
@XSockets
XSockets / MyPipeline.cs
Created October 28, 2013 19:52
Custom Pipeline in XSockets.NET
/// <summary>
/// A module that lets you override the default behavior of incomming/outgoing messages
/// </summary>
public class MyPipeline : XSocketPipeline
{
//Incomming textmessage
public override void OnMessage(IXSocketController controller, ITextArgs e)
{
base.OnMessage(controller, e);
}
@XSockets
XSockets / XSocketsCluster.cs
Created October 28, 2013 18:29
A simple demo of howto configure clusters in XSockets 3.0
class Program
{
static void Main(string[] args)
{
var wss = Composable.GetExport<IXSocketServerContainer>();
//These are my siblings on the same server but other ports
//This is all that's needed to enable cluster-functionality
wss.Siblings.Add("ws://127.0.0.1:4506");
wss.Siblings.Add("ws://127.0.0.1:4507");
@XSockets
XSockets / MyMessageInterceptor.cs
Created October 28, 2013 18:22
Based on XSockets 3.0 (not yet released) A sample of how easy it is to create a PerformanceCounter in XSockets. We do this by creating interceptors (or a custom pipeline if we are only monitoring messages) NOTE: You have to run the process as admin to be able to create interceptors
/*
Note that we as always in XSockets only have to implement the interface and the framework will find the plugin.
If you wan tto you can even load assemblies with plugins at runtime (or just reference them if youre lazy)
*/
/// <summary>
/// An example of a custom message interceptor that writes to performancecounters for messages.
///
/// Note: Be sure do use thread safe techniques in interceptors
/// </summary>
@XSockets
XSockets / AssemblyRuntimeRecomposition.cs
Last active December 19, 2016 20:49
Rutime recomposition - The XSockets pluginframework can now load assemblies at runtime.
public class Zoo : IZoo
{
public IList<IAnimal> Animals { get; set; }
}
public class Frog : IAnimal
{
public string Say()
{
return "Riiiibbitt";
@XSockets
XSockets / ExportImportInterfaces.dll
Last active December 26, 2015 05:39
Example of XSockets.Pluginframework - The idea here is that we can get hold of plugins without any configuration. By having export/import attributes on our interfaces we only have to implement a interface to get the plugin functionality. So we only need a reference to the interfaces and the pluginframework.... The actual plugins may be assemblie…
//The interfaces export the correct inteface, but can also import interfaces on properties.
//The implementing class does not need to do any imports/exports. It will be taken care of....
[Export(typeof(IZoo))]
public interface IZoo
{
[ImportMany(typeof(IAnimal))]
IList<IAnimal> Animals { get; set; }
}
[Export(typeof(IAnimal))]
@XSockets
XSockets / Chat.cs
Last active December 26, 2015 04:59 — forked from MagnusThor/Foo.cshtml
A preview of what to come! We will bring you realtime ASP.NET MVC Controllers with STATE and WebSockets for .NET 4.5 solutions. But you will still be able to communicate through XSockets to other/older implementations on .NET 4/Mono.
//The RealTime controller of XSockets.NET
public class Chat : XSocketController
{
public string Nickname { get; set; }
public void ChatMessage(string text)
{
this.SendToAll(new { text, date = DateTime.Now, nickName = this.Nickname },"onChatMessage");
}
}
@XSockets
XSockets / Compose2.cs
Last active December 25, 2015 12:59
XSockets Plugin Framework - Sample 2 - Compose by configuration
//Code below will output...
/*
Name: Boston Zoo
Animals in Zoo
Type: Lion
Says: My name is gorgeous george
Is Carnivore: True
Type: Horse
Says: Where's my cowboy?
Is Carnivore: False
@XSockets
XSockets / Compose1.cs
Last active December 25, 2015 12:59
XSockets Plugin Framework - Sample 1 - Compose with Attributes
//Code below will output...
/*
Name: Boston Zoo
Animals in Zoo
Type: Lion
Says: My name is gorgeous george
Is Carnivore: True
Type: Horse
Says: Where's my cowboy?
Is Carnivore: False
@XSockets
XSockets / Appointment.cs
Last active December 25, 2015 02:09
A simple example on how to setup a notification system with XSockets.NET. The idea came from this question on Stackoverflow: http://stackoverflow.com/questions/19251699/invoke-popup-as-reminder-in-asp-net-mvc/19252198#19252198
using System;
namespace XNotify
{
public class Appointment
{
/// <summary>
/// Id of the appointment
/// </summary>
public Guid Id { get; set; }