# .NET bindings for Hydna Full bindings for Hydna's bi-directional and push protocols. More info: https://www.hydna.com/ ## Installation Install the package NuGet via terminal: mono nuget.exe install hydna.net Or via Package Manager Console: PM> Install-Package Hydna.Net ## Compatibility - Full support for .NET 2.0 - 4.5 - Full support in Unity (both Free and Pro) Please not that support for Silverlight, Windows Phone and Windows 8 is planed and will be released shortly. ## Bindings for Unity Please see https://github.com/hydna/hydna-unity-plugin for more information. ## Usage Example using a full bi-directional channel: static Channel channel; public static void Main(string[] args) { channel = new Channel(); channel.Connect("http://public.hydna.net/", ChannelMode.ReadWrite); channel.Open += c_Open; channel.Data += c_Data; channel.Closed += c_Closed; while (channel != null) Thread.SpinWait(1); } static void c_Open(object sender, ChannelEventArgs e) { Console.WriteLine("Channel is now open: " + e.Text); channel.Send("Hello world"); } static void c_Data(object sender, ChannelEventArgs e) { Console.WriteLine("Received data: " + e.Text); channel.Close(); } static void c_Closed(object sender, ChannelCloseEventArgs e) { Console.WriteLine("Channel is now closed, bye.."); channel = null; } Example how to send data (via Push) to a specific channel using C#: using Hydna.Net; // Create a new HttpApiClient HttpApiClient client = HttpApiClient.create("public.hydna.net"); // Send a "Hello world" message to the channel. client.Send("Hello world from C#"); Example how to send data (via Push) a specific channel Async using C#: using Hydna.Net; // Create a new HttpApiClient HttpApiClient client = HttpApiClient.create("public.hydna.net"); // Begin the send async operation channel. IAsyncResult result = client.BeginSend("Hello world from C#", null, null); // Wait for the response result.AsyncWaitHandle.WaitOne(); // End the async operation. client.EndSend(result); ## Testing All tests are predefined to run against `testing.hydna.net`. ### Test using mono A simple Makefile is included which can be used to invoke the embedded test suite. To run the test suite for .Net 2.0, call: $ make test20 To run all test, for all version, call: $ make test ### Test SSL in mono You need to add the certificate for the domain to test against. In order to test against **testing.hydna.net**, run the following commands from the commmand line: $ mozroots --import --ask-remove --machine $ certmgr -ssl https://testing.hydna.net