using System; using System.Collections.Generic; using System.Text; using System.Windows.Forms; namespace IndianHealthService.BMXNet { /// /// All async communications with RPMS is performed through the RemoteEventService which /// is found by calling aRemoteSession.EventServices. /// /// /// /// By default remote events are asynchronous and are not on the UI thread. The development /// must handed the events propertly and if interacting with a user interface control must use /// Invoke(). As a convinenence, InvokedControl can be set to any non-disposed Control and the /// event service is use Invoke() so that the event is triggered on the UI thread /// The Event timer, IsEventPollingEnabled and EventPollingInterval, is used by the Async RPC calls /// and is automattically turned on with IsEventPollingEnabled. If the developer turns on polling or /// changes the EventPollingInterval to be a long period, then the Async RPC calls will not respond in /// a timely manner if at all. /// /// /// public interface RemoteEventService { /// /// This event is triggered when an event named anEventType is published and the /// receiver has a subscription. Remember that this event is not on the UI-thread unless InvokedControl is properly set. /// event EventHandler RpmsEvent; /// /// This event is triggered every time the event timer is triggered, based on the EventPollingInterval. /// Remember that this event is not on the UI-thread unless InvokedControl is properly set. /// /// /// Respond quickly to this event. /// event EventHandler TimerEvent; /// /// Set InvokedControl to a form or control of your WinForm application or EHR/VueCentric component that /// will live the lifetime of your RemoteSession. The RemoteEventServices will Invoke() on the InvokedControl /// to ensure all events are triggered on the UI thread. /// Control InvokedControl { get; set; } /// /// Subscribe to an event named anEventType. These events are trigger exclusivley by other BMXNet remote services and /// travel from client-to-server-to-client. Once subscribed, the RemoteSession will poll based on the EventPollingInterval to /// see if a server-side event is waiting to be triggered on the client. /// /// The name of the event to subscribe to /// 1 if successful, otherwise it's an error. Refer to KIDS source for error codes. int Subscribe(String anEventType); /// /// Unsubscribe from an event named anEventType. Once unsubscribed, published events named anEventType will no longer /// trigger an event for this RemoteSession. /// /// The name of the event to unsubscribe from /// 1 if successful, otherwise it's an error. Refer to KIDS source for error codes. int Unsubscribe(String anEventType); /// /// Access to a RemoteEventService also allows you to publish your own events. Publishing is done through design and /// documentation to notify other developers what events you will trigger. An event is published, or triggered, by using TriggerEvent /// with the name of the event, an optional event specific string with data, and whether or not the publisher, if subsubscribed, /// wants the event published to them. /// /// Name of the event to publish /// An optional string with event specific data /// Set to True if the publisher of anEventType, that is also a subscriber to anEventType, /// also wants the event to be triggered back to them /// int TriggerEvent(String anEventType, String aParameter,bool raiseBack); /// /// EventPolling is used for RemoteService events and Async RPC calls. IsEventPollingEnabled is used /// to turn polling on and off: True for on and False for off. The Async RPC framework and remote event service /// needs polling to be turned on. /// /// /// If Async RPC's or remote events are not working debug the RemoteEventService to verify polling is enabled /// and configured. /// /// /// If using Async RPC or remote service events activate and configure the timer when your applications starts /// /// ... //Poll every 10000 ms, or 10 seconds /// this.RemoteSession.EventServices.EventPollingInterval=10000; /// this.RemoteSession.EventServices.IsEventPollingEnabled=True; /// ... /// ... //Perhaps in another part of your application you have a small active Chat Window /// ... //Increase the frequency of polling by decreasing the EventPollingInterval to every 2 seconds /// this.RemoteSession.EventServices.EventPollingInterval=2000; /// /// bool IsEventPollingEnabled { get; set; } /// /// The number of milliseconds (ms) to wait before polling. If a polling event is currently being processed /// when a second event is trigger, the second event is skipped. It's recommended to keep this interval at /// 5000 (5 seconds) or higher. /// int EventPollingInterval { get; set; } } }