65 lines
2.6 KiB
C#
65 lines
2.6 KiB
C#
using System;
|
|
using System.Collections;
|
|
using BCG.Utilities.General;
|
|
using System.IO;
|
|
using System.Collections.Generic;
|
|
using mbts;
|
|
|
|
namespace BCG {
|
|
public delegate void PubSubServerConnectionStatusChange(string peerURL, bool connection);
|
|
public delegate void PubSubServerDataDelegate(string sender, byte[] data);
|
|
/// <summary>
|
|
/// Encapsulates PubsubServer's communication with the
|
|
/// rest of the world. Has send and get methods, and also
|
|
/// an event to tell if a client connects or disconnects.
|
|
/// this event is prompted by the doWork.
|
|
/// </summary>
|
|
public interface IPubsubMessageHub : IWorker {
|
|
/// <summary>
|
|
/// register or unregister callback for data. The data can either be received on this callback
|
|
/// on an arbitrary thread, or polled via getUpdates
|
|
/// </summary>
|
|
/// <param name="?"></param>
|
|
void register_data_callback(PubSubServerDataDelegate del);
|
|
/// <summary>
|
|
/// registers a connection callback. this callback
|
|
/// will be fired within the doWork call.
|
|
/// </summary>
|
|
/// <param name="del"></param>
|
|
/// <param name="register"></param>
|
|
void register_connection_callback(PubSubCallbacks.PubSubServerConnectionStatusChange del);
|
|
/// <summary>
|
|
/// this is where this interface starts communication with the
|
|
/// rest of the world. Obvioulsy, the resgiters should be
|
|
/// called before the start, or else the user might miss
|
|
/// connections and data.
|
|
/// </summary>
|
|
void activate();
|
|
/// <summary>
|
|
/// Gets the updates and the source of the data
|
|
/// from the clients. Returns either if timeout
|
|
/// expires or maxElements have been fetched. The string
|
|
/// in the pair is the client url
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="data"></param>
|
|
List<Pair<string, byte[]>> get_updates(TimeSpan timeout, int maxElements);
|
|
// same as above, but gets all updates that are queued up
|
|
List<Pair<string, byte[]>> get_all_updates();
|
|
/// <summary>
|
|
/// sends data to the receiver.
|
|
/// </summary>
|
|
/// <param name="receiver"></param>
|
|
/// <param name="data"></param>
|
|
//bool send(string receiver, byte[] data);
|
|
bool send(string receiver, bts.PubSubServerMessage ps_msg);
|
|
/// <summary>
|
|
/// sends the data stored in the current position in the Stream.
|
|
/// </summary>
|
|
/// <param name="receiver"></param>
|
|
/// <param name="str"></param>
|
|
/// <returns></returns>
|
|
//bool send(string receiver, Stream str);
|
|
}
|
|
}
|