using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.ServiceModel; using Thoughtworks.SAOT.Object; namespace Thoughtworks.SAOT.Service { [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple)] public class MessageSender : IMessageSender { IMessageSenderCallBack _CallBack; public MessageSender() { } public void Init() { this._CallBack = OperationContext.Current.GetCallbackChannel<IMessageSenderCallBack>(); EventEngine.MessageSending += new EventHandler<Message>(Tool_MessageSending); EventEngine.HeartBeatEvent += new EventHandler(Tool_HeartBeatEvent); } void Tool_HeartBeatEvent(object sender, EventArgs e) { try { this._CallBack.SendHeartBeat(); } catch (Exception ex) { if ((ex as System.ServiceModel.CommunicationObjectAbortedException) != null) { EventEngine.HeartBeatEvent -= this.Tool_HeartBeatEvent; } } } void Tool_MessageSending(object sender, Message e) { try { this._CallBack.SendMessage(e); } catch (Exception ex) { if ((ex as System.ServiceModel.CommunicationObjectAbortedException) != null) { EventEngine.MessageSending -= this.Tool_MessageSending; } } } } }
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)