78 lines
2.9 KiB
C#
78 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.IO;
|
|
using BCG.Utilities.General;
|
|
|
|
namespace BCG {
|
|
/// <summary>
|
|
/// This is the interface that both the PublisherCore and the
|
|
/// SubscriberCore use to communicate with the PubsubServer.
|
|
/// This manages the exchange of information to one
|
|
/// pubsub server.
|
|
/// Based on the URL, its constructed by the
|
|
/// PubsubServerConnectionFactory. All PubCores share
|
|
/// common IPubsubServerConnection for each URL, while
|
|
/// every instance of the SubscriberCore guarantees a new
|
|
/// connection to the Pubsub.
|
|
/// Its supposed to be used from a single thread. If
|
|
/// multiple threads need to communicate to the PubSub, they
|
|
/// should create their own Subscribers.
|
|
/// </summary>
|
|
public interface IPubSubServerConnection : IDisposable, IWorker {
|
|
/// <summary>
|
|
/// The delegate is fired signalling if the data send was
|
|
/// successful or not
|
|
/// </summary>
|
|
//void sendWithConfirmation(byte[] data, ref string confId);
|
|
/// <summary>
|
|
/// send is a non waiting call with no guarantee
|
|
/// of data being delivered
|
|
/// </summary>
|
|
// void send(byte[] data);
|
|
// /// <summary>
|
|
// /// similiar to above
|
|
// /// </summary>
|
|
//void send(Stream str);
|
|
//void send(PubSubMessage msg);
|
|
void send(bts.PubSubClientMessage ps_msg);
|
|
//void send_with_confirmation(PubSubMessage msg, ref string confId);
|
|
/// <summary>
|
|
/// Returns with 0 or more elements, iff the timeout
|
|
/// expires or maxElements have been reached (selective polling),
|
|
/// whatever comes first.
|
|
/// For example, a timeout of TimeSpan.max and maxElements of 1,
|
|
/// would wait until it gets the first element and returns
|
|
/// with it.
|
|
/// A timeout of 0 and maxElements
|
|
/// of Int32.Max would return all the messages it has
|
|
/// received between last getUpdates and this call.
|
|
/// </summary
|
|
IEnumerable<bts.PubSubServerMessage> get_updates(TimeSpan timeout, int maxElements);
|
|
/// <summary>
|
|
/// server URL to which the connection is made
|
|
/// </summary>
|
|
string server_url { get; }
|
|
/// <summary>
|
|
/// client URL as seen by the server. if a connection has not
|
|
/// been established (as can happen in TCP) an empty string
|
|
/// is returned
|
|
/// </summary>
|
|
string client_url { get; }
|
|
|
|
/// <summary>
|
|
/// registers the callback to receive
|
|
/// connection notifications
|
|
/// </summary>
|
|
void register_connection_callback(PubSubServerConnectionStatusChange del);
|
|
|
|
/// <summary>
|
|
/// registers callbacks to reveive data
|
|
/// </summary>
|
|
/// <param name="del"></param>
|
|
void register_data_callback(PubSubServerDataDelegate del);
|
|
|
|
//void register_send_confirmation_callback(SendConfirmationDelegate del);
|
|
}
|
|
}
|