Created
October 30, 2013 07:22
-
-
Save XSockets/7228347 to your computer and use it in GitHub Desktop.
Custom pipeline with performance counter
This file contains hidden or 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
/// <summary> | |
/// A module that lets you override the default behavior of incomming/outgoing messages | |
/// </summary> | |
public class MyPipeline : XSocketPipeline | |
{ | |
/// <summary> | |
/// A performance counter for messages | |
/// </summary> | |
private static readonly XSocketsMessageCounter MessageCounter; | |
static MyPipeline() | |
{ | |
MessageCounter = new XSocketsMessageCounter(); | |
} | |
//Incomming textmessage | |
public override void OnMessage(IXSocketController controller, ITextArgs e) | |
{ | |
MessageCounter.IncrementIn(); | |
base.OnMessage(controller, e); | |
} | |
//Outgoing textmessage | |
public override ITextArgs OnSend(IXSocketProtocol protocol, ITextArgs e) | |
{ | |
MessageCounter.IncrementOut(); | |
return base.OnSend(protocol, e); | |
} | |
//Incomming binarymessage | |
public override void OnMessage(IXSocketController controller, IBinaryArgs e) | |
{ | |
MessageCounter.IncrementIn(); | |
base.OnMessage(controller, e); | |
} | |
//Outgoing binarymessage | |
public override IBinaryArgs OnSend(IXSocketProtocol protocol, IBinaryArgs e) | |
{ | |
MessageCounter.IncrementOut(); | |
return base.OnSend(protocol, e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment