ajax - How to get HTTP request and response from WebSocket connection -


currently, using standard setup node.js + passport + ajax webserver, backbone on client, , app server exposing apis back-end. client makes ajax request node, housecleaning such checking session authentication, passes request along app server.

we experimenting replacing ajax portion between client , node websockets. part have working fine. using passport check if request authenticated. standard node route, request , response included trivial task, i'm not sure how socket.

var server = http.createserver(app).listen(port); var io = socketio.listen(server); var namespaced = io.of('/socket/test'); namespaced.on('connection', function (socket) {     console.log('a user connected /socket/test');      socket.on('fetch', function (args) {         // client has sent socket message functionally replace ajax request         // authenticate session here - how request??     }); }); 


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -