Giter Club home page Giter Club logo

csharp's Introduction

Emitter C# SDK

This repository contains C# client for .Net Framework, .Net Micro Framework and WinRT for Emitter (see also on Emitter GitHub). Emitter is an open-source real-time communication service for connecting online devices. At its core, emitter.io is a distributed, scalable and fault-tolerant publish-subscribe messaging platform based on MQTT protocol and featuring message storage.

The current version supports several .Net Frameworks:

  • .Net Framework (2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1)
  • .Net Micro Framework 4.2, 4.3 and 4.4
  • Mono (for Linux O.S.)

The current version also supports WinRT platforms:

  • Windows 8.1
  • Windows Phone 8.1
  • Windows 10

This library provides a nicer MQTT interface fine-tuned and extended with specific features provided by emitter.io. The library is based upon the M2MQTT library written by Paolo Patierno and released under Eclipse Public License.

Build Notes

The solution contains C# projects for Micro Framework.

Alternatively, the files can be downloaded from here:

Nuget

To install Emitter, run the following command in the Package Manager Console:

Install-Package Emitter

Usage

Below is a sample program written using this C# client library. This demonstrates a simple console chat app where the messages are published to chat channel and every connected client receives them in real-time.

// Creating a connection to emitter.io service.
var emitter    = new Emitter.Connection();
var channelKey = "<channel key for 'chat' channel>";

// Connect to emitter.io service
emitter.Connect();

// Handle chat messages
emitter.On(channelKey, "chat", (channel, msg) =>
{
    Console.WriteLine(Encoding.UTF8.GetString(msg));
});

// Publish messages to the 'chat' channel
string text = "";
Console.WriteLine("Type to chat or 'q' to exit...");
do
{
    text = Console.ReadLine();
    emitter.Publish(channelKey, "chat", text);
}
while (text != "q");

// Disconnect the client
emitter.Disconnect();

To generate a channel key using the secret key provided, the GenerateKey method can be used.

// Generate a read-write key for our channel
emitter.GenerateKey(
    "<secret key>", 
    "chat", 
    Messages.EmitterKeyType.ReadWrite, 
    (response) => Console.WriteLine("Generated Key: " + response.Key)
    );

csharp's People

Contributors

kelindar avatar pickettskf avatar ppatierno avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.