static async Task Main() { using IStompClient client = new StompWebsocketClient(new Uri($"ws://{BrokerHost}:{BrokerPort}/ws")); //using IStompClient client = new StompTcpClient(BrokerHost, BrokerPort); Console.WriteLine("Connecting..."); await client.Connect(new Dictionary <string, string>() { { "User", User }, { "Passcode", Passcode }, }); Console.WriteLine("Connected."); await client.Subscribe <string>($"/topic/{NextJSTopic}", new Dictionary <string, string>(), NextJsSaysHello); var timer = new System.Timers.Timer(2000); timer.AutoReset = true; timer.Elapsed += new System.Timers.ElapsedEventHandler(async(object sender, System.Timers.ElapsedEventArgs e) => { Console.WriteLine("Saying Hello..."); await client.Send("Hello from dotnet core!!", $"/topic/{DotNetTopic}", new Dictionary <string, string>()); }); timer.Start(); Console.WriteLine("Press enter to stop."); Console.ReadLine(); }
public void StartClient() { this.stompClient = new StompWebsocketClient("localhost:5555/test"); this.stompClient.Connected += this.Connected; this.stompClient.Connect(); }
public static void Main(string[] args) { IStompClient client = new StompWebsocketClient("ws://localhost:8080/ws/websocket"); client.Connect(new Dictionary <string, string>()); client.Subscribe <Greeting>("/topic/greetings", new Dictionary <string, string>(), SayHello); client.Send(new HelloMessage() { Name = "Nikita" }, "/app/hello", new Dictionary <string, string>()); Console.ReadKey(true); }
public void ServerAvailable() { var stompServer = new StompWebsocketServer(5555); var stompClient = new StompWebsocketClient("127.0.0.1:5555"); var raisedEvent = Assert.RaisesAny <ConnectedEventArgs>( handler => stompClient.Connected += handler, handler => stompClient.Connected -= handler, () => { stompClient.Connect(); Thread.Sleep(100); }); }