The problem I'm trying to tackle is we have an app that has a mobile client as well as an admin-only web client which both connect to the back-end using Socket.IO/Feathers client.
I'd like to have a way to apply hooks or otherwise modify the query or response by determining whether the request came from the admin client or not.
From what I've tried so far, I've found that I can't access headers on server-side such as the originating client URI (i.e. to determine whether the request came from admin.mysite.com) using Socket.IO provider, and that adding headers via the Socket.IO doesn't work when the transport is set to websockets because of the spec.
I've also looked into channels which looks like a great idea, but the examples put people into channels based on user data and not request data.
Does anyone know of a reasonable way to accomplish this?
The Feathers Socket.io transport documentation shows how to pass information from Socket.io to Feathers. socket.request
contains the information of the initiating HTTP request.
app.configure(socketio(function(io) {
io.use(function (socket, next) {
socket.feathers.isSomeServer = socket.request.connection.remoteAddress === myServerIp;
next();
});
}));
Now you can check params.isSomeServer
.