Git Product home page Git Product logo

cometd.net's Introduction

CometD.NET is a project to provide an implementation of the Bayeux protocol in .NET. The client code is ported based on the source code from the java client found at http://cometd.org/. You can also visit that page if you are looking for a CometD server.


This is the CometD.NET project home.

cometd/bayeux           - The Bayeux Specification
cometd/client 		- The .NET client library
cometd/common		- Classes from the java cometd common directory

RUNNING COMETD CLIENT

The CometD.NET client won't work without a bayeux/cometd server to connect to. If you have installed the cometd server from cometd.org, you should be able to connect to it.

DEPENDENCIES

The CometD.NET client library is set to compile with .NET Framework 3.5, and does not support .NET Framework Client Profile. If you get an error about a dependency on "System.Web.Extensions", you should go to your project properties and change to a framework without Client Profile.

USAGE

Usage is basically the same as in the java-client (http://cometd.org/documentation/cometd-java/client). HakanL have made a simple command-line tool which utilizes the basic functionality (http://github.com/HakanL/Auto-Deployment). You can also look at https://github.com/Oyatel/oyatel-api-examples/blob/master/csharp/Oyatel.Connect.Tutorial/StreamingEvents.cs to see how we use it to communicate with our own bayeux-server.

BASIC USAGE EXAMPLE

using Cometd.Client;
using Cometd.Client.Transport;
using Cometd.Bayeux;
using Cometd.Bayeux.Client;
using Cometd.Common;

...
        class Listener : IMessageListener
        {
                public void onMessage(IClientSessionChannel channel, IMessage message)
                {
                    // Handle the message
		    Console.WriteLine(message);
                }
        }

        static void Main(string[] args)
        {
            // Handshake
            String url = "http://localhost:8080/cometd ";
            BayeuxClient client = new BayeuxClient(url, new List<ClientTransport>() { new LongPollingTransport(null) });
            
	    client.handshake();
	    client.waitFor(1000, new List<BayeuxClient.State>() { BayeuxClient.State.CONNECTED });

            // Subscription to channels
            IClientSessionChannel channel = client.getChannel("/service/echo");
            channel.subscribe( new Listener() );

            // Publishing to channels
            Dictionary<String, Object> data = new Dictionary<String, Object>();
            data.Add("bar", "baz");
            channel.publish(data);

            // Disconnecting
            client.disconnect();
	    client.waitFor(1000, new List<BayeuxClient.State>() { BayeuxClient.State.DISCONNECTED });
        }

cometd.net's People

Contributors

hakanl avatar magnusga avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  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.