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); /// /// 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. /// public interface IPubsubMessageHub : IWorker { /// /// register or unregister callback for data. The data can either be received on this callback /// on an arbitrary thread, or polled via getUpdates /// /// void register_data_callback(PubSubServerDataDelegate del); /// /// registers a connection callback. this callback /// will be fired within the doWork call. /// /// /// void register_connection_callback(PubSubCallbacks.PubSubServerConnectionStatusChange del); /// /// 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. /// void activate(); /// /// 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 /// /// /// List> get_updates(TimeSpan timeout, int maxElements); // same as above, but gets all updates that are queued up List> get_all_updates(); /// /// sends data to the receiver. /// /// /// //bool send(string receiver, byte[] data); bool send(string receiver, bts.PubSubServerMessage ps_msg); /// /// sends the data stored in the current position in the Stream. /// /// /// /// //bool send(string receiver, Stream str); } }