diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/jaegertracing/thrift/contrib/zeromq/csharp/TZmqServer.cs | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/jaegertracing/thrift/contrib/zeromq/csharp/TZmqServer.cs')
-rw-r--r-- | src/jaegertracing/thrift/contrib/zeromq/csharp/TZmqServer.cs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/jaegertracing/thrift/contrib/zeromq/csharp/TZmqServer.cs b/src/jaegertracing/thrift/contrib/zeromq/csharp/TZmqServer.cs new file mode 100644 index 000000000..535c623d0 --- /dev/null +++ b/src/jaegertracing/thrift/contrib/zeromq/csharp/TZmqServer.cs @@ -0,0 +1,56 @@ +using System; +using Thrift; +using Thrift.Server; +using Thrift.Transport; +using Thrift.Protocol; +using ZMQ; +using System.IO; + +using System.Collections.Generic; + +namespace ZmqServer +{ + public class TZmqServer + { + Socket _socket ; + TProcessor _processor; + + void debug (string msg) + { + //Uncomment to enable debug +// Console.WriteLine (msg); + } + + public TZmqServer (TProcessor processor, Context ctx, String endpoint, SocketType sockType) + { + new TSimpleServer (processor,null); + _socket = ctx.Socket (sockType); + _socket.Bind (endpoint); + _processor = processor; + } + + public void ServeOne () + { + debug ("Server_ServeOne"); + Byte[] msg = _socket.Recv (); + MemoryStream istream = new MemoryStream (msg); + MemoryStream ostream = new MemoryStream (); + TProtocol tProtocol = new TBinaryProtocol (new TStreamTransport (istream, ostream)); + _processor.Process (tProtocol, tProtocol); + + if (ostream.Length != 0) { + byte[] newBuf = new byte[ostream.Length]; + Array.Copy (ostream.GetBuffer (), newBuf, ostream.Length); + debug (string.Format ("Server_ServeOne sending {0}b", ostream.Length)); + _socket.Send (newBuf); + } + } + + public void Serve () + { + while (true) + ServeOne (); + } + } +} + |