public void StartStompReceiver(string serverPortTopic) { string server = "localhost"; int port = StompConnection.DEFAULT_PORT; string topic = "/topic/Teddi.Sensor"; string user = ""; string password = ""; ParseServerPortTopic(serverPortTopic, ref server, ref port, ref topic, ref user, ref password); // Create STOMP connection stompConnection = null; try { stompConnection = new StompConnection(server, port, user, password); } catch (Exception e) { Console.WriteLine("ERROR: Cannot connect to STOMP server: " + e.Message + "."); } if (stompConnection != null) { // Subscribe to a topic stompConnection.Subscribe(topic); // Create threaded listener and add a message handler stompListener = new StompListener(stompConnection); stompListener.ReceivedMessage += stompListener_ReceivedMessage; } }
public StompListener(StompConnection stompConnection) { this.stompConnection = stompConnection; Start(); }