All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.signalr4j.client.hubs.Subscription Maven / Gradle / Ivy

There is a newer version: 2.0.4
Show newest version
/*
Copyright (c) Microsoft Open Technologies, Inc.
All Rights Reserved
See License.txt in the project root for license information.
*/

package com.github.signalr4j.client.hubs;

import java.util.ArrayList;
import java.util.List;

import com.github.signalr4j.client.Action;

import com.google.gson.JsonElement;

/**
 * Represents a subscription to a message
 */
public class Subscription {
    private List> mReceived = new ArrayList>();

    /**
     * Triggers the "Received" event
     * 
     * @param data
     *            Event data
     * @throws Exception
     */
    void onReceived(JsonElement[] data) throws Exception {
        for (Action handler : mReceived) {
            handler.run(data);
        }
    }

    /**
     * Add a handler to the "Received" event
     * 
     * @param received
     *            Event handler
     */
    public void addReceivedHandler(Action received) {
        mReceived.add(received);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy