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 / AzureServiceBusScaling.cs
Last active August 29, 2015 14:19
Override the default scaling of XSockets and use Azure Service Bus instead.
using System;
using System.Configuration;
using System.Linq;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
using XSockets.Core.Common.Enterprise;
using XSockets.Core.Common.Socket;
using XSockets.Core.Common.Socket.Event.Interface;
using XSockets.Core.Common.Utility.Logging;
using XSockets.Core.Common.Utility.Serialization;
namespace DataSyncBasic2.DataSync
{
/// <summary>
/// Sync commands... Just to avoid string in code
/// </summary>
public static class DataSyncCommand
{
public const string Add = "add";
public const string Update = "update";
public const string Delete = "delete";
@XSockets
XSockets / Serilog.Sink.XSockets.Sample.cs
Last active August 29, 2015 14:04
Serilog Sink for XSockets.NET, clients will receive messages based on LogEventLevel
//Custom Logger Configuration in XSockets by implementing IDefaultLogger
public class MyLogger : IDefaultLogger
{
public ILogger Logger
{
get
{
return new LoggerConfiguration().MinimumLevel.Verbose()
.WriteTo.XSockets()
.CreateLogger();
@XSockets
XSockets / Client.cs
Last active August 29, 2015 14:00
Sending binary message with metadata from C# client to XSockets server
//client memeber is of type IXSocketClient that is connected to controller "foo"
//Read a dummy file from disk
var bytes = File.ReadAllBytes(@"c:\temp\HelloWorld.txt");
//Create message with the custom helper "CreateBinaryMessage" and add the metadata of choice
var binaryMessage = client.CreateBinaryMessage(bytes, new FileInfo { FileName = "HelloWorld.txt" });
//Send the binary message
client.Send(binaryMessage);
@XSockets
XSockets / xsockets-docs-3
Created January 14, 2014 16:53
XSockets-Docs-3
# XSockets 3.* Docs #
## Supported Platforms ##
### Server ###
XSockets runs pretty much anywhere and do note that the server ALWAYS deliver websocket-support. Feel free to compare us to alternative frameworks!
Platform Requirements Websockets WebRTC
Windows .NET 4+ Yes Yes
@XSockets
XSockets / SimpleProcotol.cs
Created January 13, 2014 09:15
Shows a simple custom protocol (plugin) for XSockets.NET. You will from 3.0.3 be able to communicate between any clients no matter protocol. This means that you with ease can talk between any devices talking TCP/IP.
/// <summary>
/// A really simple/stupid protocol.
/// The magic here is that clients connected to this protocol (TelNet, Arduino, Netduino or whatever) will be able
/// to communicate cross-protocol with client talking RFC6455 for example (or any other implemented protocol).
/// </summary>
public class SimpleProtocol : XSocketProtocol
{
/// <summary>
/// Extract the path (controller name) from the handshake
/// </summary>
@XSockets
XSockets / XSockets-3.*-Docs
Last active December 30, 2015 13:59
XSockets-3.*-Docs
# XSockets 3.* Docs #
## Supported Platforms ##
### Server ###
XSockets runs pretty much anywhere and do note that the server ALWAYS deliver websocket-support. Feel free to compare us to alternative frameworks!
Platform Requirements Websockets WebRTC
Windows .NET 4+ Yes Yes
@XSockets
XSockets / CombinedMessage.js
Last active December 29, 2015 16:28
XSockets support sending text data together with binary data over websockets. Event though the protocol does no support it... Try that with somethingR ;)
//Create a new XSockets text message.... the event is foo... The data is {lion:'grrr', p:Date()}
var myJson = new XSockets.Message("foo", { lion: 'grrr', p: Date() });
//Create a XSockets binary message and attach the text to it... (we call canvasToBuffer() to get hold of some data)
var binaryMessage = new XSockets.BinaryMessage(myJson, canvasToBuffer(),
//The callback where we have data in the arrayBuffer...
function (arrayBuffer) {
// Okey, the buffer is created and wrapped in our simple "subprotocol".... send it!
ws.send(arrayBuffer.buffer);
});
@XSockets
XSockets / bm.cs
Last active December 26, 2015 23:29
test
public class MyBinaryController : XSocketController
{
public override void OnMessage(Core.Common.Socket.Event.Interface.IBinaryArgs binaryArgs)
{
var bm = new BinaryMessage(binaryArgs);
this.Send(bm.BinaryArgs);
this.Send(bm.TextArgs);
}
}
@XSockets
XSockets / MyPipelineWithPerformanceCounter.cs
Created October 30, 2013 07:22
Custom pipeline with performance counter
/// <summary>
/// A module that lets you override the default behavior of incomming/outgoing messages
/// </summary>
public class MyPipeline : XSocketPipeline
{
/// <summary>
/// A performance counter for messages
/// </summary>
private static readonly XSocketsMessageCounter MessageCounter;