Reputation: 57
I am trying to something similar to this "Path variables in Spring WebSockets @SendTo mapping" But I want to send a table name as additional information to @SubscribeMapping("/topic/data"). "tablename" can be anything based on my need(what I want to set), it should concatenate @SubscribeMapping("/topic/data/{tablename}") and on the server side, I would like to access the tablename to get the data from the database. I have tried the solution mentioned in the above post lien @DestinationVariable but I think I am missing something.
Upvotes: 2
Views: 2764
Reputation: 57
on the server side :
@SubscribeMapping("/getviewschema/{tablename}")
public JSONObject getViewSchema(@DestinationVariable String tablename) throws Exception
{
DataManager manager = new DataManager();
return manager.getViewJSONSchema(tablename);
}
On the client side
socket.stomp.subscribe("/app/getviewschema/"+service.tablename,function(data)
{
listenerview.notify(JSON.parse(data.body));
});
Upvotes: 2