I am writing an open-source application for real-time messaging in web. In my application clients from browser can subscribe on channels. But every channel belongs to a certain namespace which determines channel's settings:
client.subscribe('/football/news', function(message) {
// message from channel received
});
where football
is namespace name and news
is channel name. football
can be a default namespace for project and in this case we can write in this way:
client.subscribe('/news', function(message) {
// message from channel received
});
i.e. without namespace name. This is how it works right now.
But my question is about /
path separator. Is it ok? We need the way do separate namespace name and channel name. /
usage was influenced by Bayeux
protocol spec. But maybe it would be more simple and correct to write in such manner:
client.subscribe('football', 'news', function(message) {
// message from channel received
});
or with default namespace:
client.subscribe(null, 'news', function(message) {
// message from channel received
});
or even:
client.subscribe('news', function(message) {
// message from channel received
});
I personally feel that the second way is better. But before refactoring I decided to ask for your opinion.