com.github.signalr4j.client.hubs.Subscription Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of signalr4j Show documentation
Show all versions of signalr4j Show documentation
A java client library for accessing SignalR WebSocket endpoints.
/*
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);
}
}