Ejemplo n.º 1
0
        public void Start()
        {
            var registry = new ExtensionRegistry();
            //registry.AddRequiredExtension(new JsonExtension());
            if (MessagesPerAck != 0)
            {
                registry.AddRequiredExtension(new AckExtension
                {
                    MessagesPerAck = MessagesPerAck,
                    AckExpireTime = TimeSpan.FromSeconds(120) // as we queue up msgs a lot faster than they can be sent.
                });
            }

            registry.AddRequiredExtension(new DotNetTypeExtension());
            var parts = RemoteHost.Split(':');
            var port = int.Parse(parts[1]);

            _client = new SharpMessagingClient("TestClient", registry);
            _client.Start(parts[0], port);
            _client.FrameReceived = OnTimingFrame;

            //start timing
            var buffer = Encoding.ASCII.GetBytes(DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss.ffff"));
            _client.Send(new MessageFrame(buffer));

            Console.WriteLine("All enqueued");
        }
Ejemplo n.º 2
0
 public static void CreateClient()
 {
     var registry = new ExtensionRegistry();
     registry.AddRequiredExtension(new AckExtension()
     {
         MessagesPerAck = 10,
         AckExpireTime = TimeSpan.FromSeconds(1)
     });
     //registry.AddRequiredExtension(new FastJsonExtension());
     var client = new SharpMessagingClient("MyClient", registry);
     client.Start("localhost", 8334);
     client.Send(new MessageFrame("Hello"));
     Console.WriteLine("Sent!");
     Console.ReadLine();
 }
Ejemplo n.º 3
0
 public void Start(int port)
 {
     var registry = new ExtensionRegistry();
     registry.AddOptionalExtension(new AckExtension()
     {
         MessagesPerAck = MessagesPerAck,
         AckExpireTime = TimeSpan.FromSeconds(1)
     });
     registry.AddOptionalExtension(new AckExtension());
     registry.AddOptionalExtension(new DotNetTypeExtension());
     registry.AddOptionalExtension(new FastJsonExtension());
     _server = new SharpMessagingServer(registry);
     _server.FrameReceived = OnTimeSync;
     _server.ClientDisconnected = OnClientDisconnect;
     _server.Start(port);
 }
Ejemplo n.º 4
0
        private static void Main(string[] args)
        {
            var registry = new ExtensionRegistry();
            registry.AddOptionalExtension(new AckExtension()
            {
                MessagesPerAck = 200,
                AckExpireTime = TimeSpan.FromSeconds(1)
            });
            registry.AddOptionalExtension(new DotNetTypeExtension());
            registry.AddOptionalExtension(new FastJsonExtension());
            var server = new SharpMessagingServer(registry);
            server.FrameReceived = OnFrame;
            server.Start(8334);

            CreateClient();

            Console.ReadLine();
        }