Send() 공개 메소드

Sends a message to the specified address.
public Send ( string address, string message ) : void
address string The address.
message string The message.
리턴 void
        private static void WaitForSubscriptionConformation(StompClient client, string queue)
        {
            var subscribed = false;
            var retryCount = 20;
            var message = "connected to:" + queue;
            var originalMessageHandler = client.OnMessage;

            client.OnMessage = null;
            client.OnMessage = msg => subscribed = msg.Body == message;

            while (!subscribed && retryCount > 0)
            {
                client.Send(queue, message);

                Thread.Sleep(1500);
                retryCount--;
            }

            client.OnMessage = originalMessageHandler;

            if (retryCount == 0)
            {
                throw new InvalidOperationException("Timeout waiting for stomp broker to respond");
            }
        }
예제 #2
0
        private static void Main(string[] args)
        {
            const string address = "ws://localhost:8181/";
            var wsListener = new StompWebsocketListener(address);

            wsListener.OnConnect
                += stompClient =>
                       {
                           Console.WriteLine("a new client connected!");
                           stompClient.OnMessage += msg => Console.Out.WriteLine("msg received: {0} {1}", msg.Command, msg.Body);
                       };

            var server = new StompServer(wsListener);
            server.Start();

            var client = new StompClient(new WebTransportTransport(address));
            client.Connect();
            client.Send("/queue/test", "hi there. you are the first to connect");

            Console.Out.WriteLine("Press [Enter] to stop the server");
            Console.ReadLine();
        }