Created
November 8, 2010 21:23
-
-
Save andreasohlund/668297 to your computer and use it in GitHub Desktop.
SSSBMessageForwarder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Forwarder: IWantToRunAtStartup | |
{ | |
readonly IBus _bus; | |
readonly ITransport _transport; | |
public Forwarder(IBus bus, IYourOwnTransportFactory transportFactory) | |
{ | |
_bus = bus; | |
_transport = transportFactory.GetTransport(); | |
_transport.TransportMessageReceived += TransportMessageReceived; | |
} | |
void TransportMessageReceived(object sender, TransportMessageReceivedEventArgs e) | |
{ | |
var message = e.Message.Body[0]; | |
_bus.SendLocal(message); | |
} | |
public void Run() | |
{ | |
_transport.Start(); | |
} | |
public void Stop() | |
{ | |
_transport.Dispose(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment