Build and scale real-time applications.
Stop using AJAX polling and Comet to replicate a TCP connection, and just use one. Alchemy takes care of the guts of socket programming and leaves you with what you care about - your application. Alchemy handles breaking itself out into threads and scaling, allowing you to handle hundreds of thousands of simultaneous connections on modest hardware; all this, and you only have to care about a few lines of code.
Usage
//...refs
using Alchemy;
using Alchemy.Classes;
static void Main(string[] args)
{
// instantiate a new server - acceptable port and IP range,
// and set up your methods.
var aServer = new WebSocketServer(81, IPAddress.Any) {
OnReceive = OnReceive,
OnSend = OnSend,
OnConnect = OnConnect,
OnConnected = OnConnected,
OnDisconnect = OnDisconnect,
TimeOut = new TimeSpan(0, 5, 0)
};
aServer.Start();
}
static void OnConnected(UserContext context)
{
Console.WriteLine("Client Connection From : " +
aContext.ClientAddress.ToString());
}
//...etc
You can run Alchemy Websockets as a console application, Windows service, Linux daemon under Mono, or any configuration that works best for you.
Alchemy Websockets is available as a NuGet package (as of May 31.) Alternatively, Alchemy Websockets is a Visual Studio 2010 project. It can be loaded in the free Visual C# Express and Monodevelop as well (and potentially other compatible IDEs.)
Alchemy Websockets runs in Mono and Windows .NET environments. It officially supports hybi-00, hybi-10, hybi-17, and the official RFC6455.
You can also use Alchemy Websockets as a client to connect to other WebSocket servers using the RFC6455 protocol; this allows you to build servers communicating with each other.
Setting up Alchemy Websockets as a Client
//...refs
using Alchemy;
using Alchemy.Classes;
static void Main(string[] args)
{
var aClient = new WebSocketClient("ws://alchemywebsockets.net:81/chat"){
OnReceive = OnReceive,
OnSend = OnSend,
OnConnect = OnConnected,
OnConnected = OnConnect,
OnDisconnect = OnDisconnect
});
aClient.Connect();
aClient.Send("Hey!"); // string or byte[]
aClient.Disconnect();
}
static void OnReceive(UserContext context)
{
Console.WriteLine("The server said : " + context.DataFrame.ToString());
}
//...etc
Example Project
An example application can be seen on alchemy-websockets-example
Client Library
The client library is not necessary; it simply provides a helpful abstraction for older websockets that handles a flash fallback using websocket-js. You can download the client javascript library at alchemy-websockets-client-library.
License
Licensed under LGPL and MIT. This makes it compatible with GPL licensing and allows you to use Alchemy in both commercial and open-source projects with no limitations or liabilities. Alchemy Websockets is Copyright 2011, Olivine Labs, LLC.