erizet / SignalA

A SignalR client for Android.
Apache License 2.0
193 stars 90 forks source link

SignalA

Important note

I will no longer update this library.

Updates

2014-02-27 version 0.20

2014-02-14 version 0.16

2014-01-17 version 0.15

2014-01-01 version 0.14

2013-08-12 version 0.13

2013-07-31 version 0.12

2013-06-27 version 0.11

Two fixes in this release.

2013-02-20 version 0.10beta released

I've changed a coupe of things in this release.

2013-02-20 version 0.9beta released

Version 0.9beta uses the SignalR-protocol version 1.2 which is used in the 1.0 release of SignalR. It has also (beta)support for groups.

Description

SignalA is a SignalR-client for Android. It's implemented as a Android-library. At this moment is long polling the only implemented transport. Long polling is a separate library. Http-requests in the Long polling library is using basic-http-client.

Add SignalA to your project

SignalA is published on Maven Central as a ARR. If you're using Android Studio/Gradle all you have to do is add it on your gradle build:

dependencies {
    compile 'com.github.erizet.signala:signala-longpolling:0.20'
}

How to use?

Add the following code to your activity.

  String url = "http://<address to your SignalR-server>";
  con = new com.zsoft.signala.Connection(url, this, new LongPollingTransport()) {

        @Override
        public void OnError(Exception exception) {
            Toast.makeText(DemoActivity.this, "On error: " + exception.getMessage(), Toast.LENGTH_LONG).show();
        }

        @Override
        public void OnMessage(String message) {
            Toast.makeText(DemoActivity.this, "Message: " + message, Toast.LENGTH_LONG).show();
        }

        @Override
        public void OnStateChanged(StateBase oldState, StateBase newState) {
        }
    };

To start and stop the SignalA connection use code similar to the following.

public void startSignalA()
{
    if(con!=null)
        con.Start();
}

public void stopSignalA()
{
    if(con!=null)
        con.Stop();
}

That's it!

For a complete sample see the Demo-project.

Limitations

Hubs don't support State yet.

Contributions

I'll be more than happy to get contributions!!!

Are you using SignalA?

If you're using SignalA I would appreciate to hear from you - where and how are you using it?

License

Copyright 2013 Erik Zetterqvist

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Disclaimer: I'm a .NET-coder and this is my first attemt to write a Java-library so bare with me.