C# Class Lawo.EmberPlusSharp.S101.S101Robot

Simulates S101 communication.
Show file Open project: Lawo/ember-plus-sharp Class Usage Examples

Public Methods

Method Description
RunAsync ( S101Client client, EmberTypeBag types, XmlReader logReader, bool sendFirstMessage ) : System.Threading.Tasks.Task

Asynchronously simulates S101 communication.

Reads messages with logReader and depending on the direction either sends them to the remote party or matches them to messages received from the remote party. If a message received from the remote party does not match the one in the log then an appropriate exception is thrown.

Subsequent messages read with logReader that match the direction of the first message read with logReader are sent if sendFirstMessage equals true; otherwise such messages are matched to the ones received from the remote party. The opposite happens with log messages of opposite direction.

Private Methods

Method Description
Dispose ( ) : void
FromXml ( string xml ) : byte[]
OnClientConnectionLost ( object sender, ConnectionLostEventArgs e ) : void
OnClientEmberDataReceived ( object sender, MessageReceivedEventArgs e ) : void
OnOutOfFrameByteReceived ( object sender, OutOfFrameByteReceivedEventArgs e ) : void
ProcessIncomingMessage ( MessageReceivedEventArgs e ) : System.Threading.Tasks.Task
ProcessIncomingOutOfFrameByte ( OutOfFrameByteReceivedEventArgs e ) : System.Threading.Tasks.Task
S101Robot ( S101Client client, EmberTypeBag types, XmlReader logReader, bool sendFirstMessage ) : System
SendEvent ( Func sendOperation ) : Task
SendMessages ( ) : void
SendMessagesAsync ( ) : System.Threading.Tasks.Task
ToXml ( byte payload ) : string
WaitAsync ( ) : System.Threading.Tasks.Task

Method Details

RunAsync() public static method

Asynchronously simulates S101 communication.

Reads messages with logReader and depending on the direction either sends them to the remote party or matches them to messages received from the remote party. If a message received from the remote party does not match the one in the log then an appropriate exception is thrown.

Subsequent messages read with logReader that match the direction of the first message read with logReader are sent if sendFirstMessage equals true; otherwise such messages are matched to the ones received from the remote party. The opposite happens with log messages of opposite direction.

, and/or /// equal null. /// There was a mismatch between an incoming message and one read from the log. /// The event occurred on the client passed to /// . /// The XML read with is invalid, see /// for details.
public static RunAsync ( S101Client client, EmberTypeBag types, XmlReader logReader, bool sendFirstMessage ) : System.Threading.Tasks.Task
client S101Client The to use.
types EmberTypeBag The types to pass to the internal , which is used to convert /// between XML payload and EmBER payload.
logReader XmlReader The to read the messages from. The messages that are /// expected to be received from the remote party as well as the ones that will be sent are read with this /// reader. The format needs to match the one written by .
sendFirstMessage bool true to send the first message read with /// ; false to wait for the first message from the remote party and match it /// to the first message read with .
return System.Threading.Tasks.Task