Skip to content
This repository has been archived by the owner on Jul 21, 2022. It is now read-only.

Commit

Permalink
Update README.
Browse files Browse the repository at this point in the history
  • Loading branch information
vegardlarsen committed Aug 23, 2017
1 parent 6df5d0f commit ae0c519
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Pusher.NET==========.NET client library for Pusher.com.Pusher.NET is structured as a Portable Class Library, but is dependent on a WebSocket implementation, which is currently only available for Windows Store apps.Install-------Using Nuget:```PM> Install-Package PusherNET```How to use----------```csharpvar pusher = new Pusher(new WebsocketConnectionFactory(), appKey);await pusher.ConnectAsync();var fooChannel = await pusher.SubscribeToChannelAsync("foo");fooChannel.EventEmitted += (sender, evt) => { Debug.WriteLine(evt.Data); };```PS! `WebsocketConnectionFactory` is currently only implemented for Windows Store apps. Feel free to contribute an implementation for other platforms.HTTPS-----Use the options object to enable HTTPS:```csharpvar pusher = new Pusher(new WebsocketConnectionFactory(), appKey, new Options { Scheme = WebServiceScheme.Secure });```Authenticators--------------If you want to use private or presence channels, you will have to implement a simple authenticator. How you do this is dependent on your existing infrastructure. You provide the authenticator through the Pusher options object:```csharpvar pusher = new Pusher(new WebsocketConnectionFactory(), appKey, new Options { Authenticator = new MyAuthenticator(whatever, parameters, youNeed) });```Event contracts---------------By default events that are raised contain a string Data field which is straight-up JSON code returned from the server. If you want statically typed access to this object, you will have to provide an event contract.An event contract is most easily created by registering with Pusher:```csharp[DataContract]class SomeDataStructure{ [DataMember(Name = "id")] public int Id { get; set; }}pusher.AddContract(EventContract.Create<SomeDataStructure>("event name"));```Now, you can elect to receive strongly typed events:```csharppusher.GetEventSubscription<SomeDataStructure>().EventEmitted += (sender, evt) { // evt.Data is SomeDataStructure Debug.WriteLine(evt.Data.Id); };```
Pusher.NET==========.NET client library for Pusher.com.Pusher.NET is structured as a Portable Class Library, but is dependent on a WebSocket implementation, which is available for .NET and Windows Store (Windows 8.1 and above) apps.Important note--------------Pusher now supplies their own library for working with Pusher in .NET, [in addition to other community supported libraries](https://pusher.com/docs/libraries#community-net). We strongly recommend you evaluate these libraries.This library was created because at the time Pusher did not supply a library that ran inside Windows Store apps (Windows 8). Since we wrote this library, the product we used it in has been discontinued, and therefore we are no longer actively maintaining it.Install-------Using Nuget:```PM> Install-Package PusherNET```How to use----------```csharpvar pusher = new Pusher(new WebsocketConnectionFactory(), appKey);await pusher.ConnectAsync();var fooChannel = await pusher.SubscribeToChannelAsync("foo");fooChannel.EventEmitted += (sender, evt) => { Debug.WriteLine(evt.Data); };```PS! `WebsocketConnectionFactory` is currently only implemented for Windows Store apps. Feel free to contribute an implementation for other platforms.HTTPS-----Use the options object to enable HTTPS:```csharpvar pusher = new Pusher(new WebsocketConnectionFactory(), appKey, new Options { Scheme = WebServiceScheme.Secure });```Authenticators--------------If you want to use private or presence channels, you will have to implement a simple authenticator. How you do this is dependent on your existing infrastructure. You provide the authenticator through the Pusher options object:```csharpvar pusher = new Pusher(new WebsocketConnectionFactory(), appKey, new Options { Authenticator = new MyAuthenticator(whatever, parameters, youNeed) });```Event contracts---------------By default events that are raised contain a string Data field which is straight-up JSON code returned from the server. If you want statically typed access to this object, you will have to provide an event contract.An event contract is most easily created by registering with Pusher:```csharp[DataContract]class SomeDataStructure{ [DataMember(Name = "id")] public int Id { get; set; }}pusher.AddContract(EventContract.Create<SomeDataStructure>("event name"));```Now, you can elect to receive strongly typed events:```csharppusher.GetEventSubscription<SomeDataStructure>().EventEmitted += (sender, evt) { // evt.Data is SomeDataStructure Debug.WriteLine(evt.Data.Id); };```
Expand Down

0 comments on commit ae0c519

Please sign in to comment.