About session.fetch()

51 views
Skip to first unread message

Beka Iglesias López

unread,
Dec 5, 2019, 5:40:11 AM12/5/19
to OpenVidu
Hello,

I am using openvidu.fetch() without any problem, but session.fetch() is giving an error to me ("is not a function" ) in openvidu-node-client part.

Regarding the documentation including as OV configuration this line...

var Session = require('openvidu-node-client').Session;

...and call before openvidu.fetch() and later session.fetch() should be enough to fetch one session info from Openvidu Server. But openvidu.fetch() returns the promise correctly and session.fetch() say that it's not a function.

Is this normal? Another people with the same problem?

Thanks in advance,

Beka
--
Beka Iglesias
Software Engineering Group
Fundació i2CAT
Gran Capità, 2-4, Nexus I, 2a planta, Barcelona

Beka Iglesias

unread,
Dec 9, 2019, 9:17:59 AM12/9/19
to OpenVidu
I don't see what I am missing regarding session.fetch and why openvidu.fetch() is working pretty well for me and not session.fetch() following the API Reference? This makes me uncapable to access activeConnections array and use close(), forceDisconnect() and forceUnpusblish() methods in Session.

Any clue regarding to this? Anything special about this that I can't see in documentation?

Pablo

unread,
Dec 10, 2019, 6:41:03 AM12/10/19
to OpenVidu
I have just tested Session.fetched method and it works fine.

My imports look like this in my Node applications:

var OpenVidu = require('openvidu-node-client').OpenVidu;
var Session = require('openvidu-node-client').Session;
var OpenViduRole = require('openvidu-node-client').OpenViduRole;


And the code using this imports is below. The line stating "console.log('FETCHED')" is triggered successfully. By the way, there's no need to call OpenVidu.fetch before calling Session.fetch.

var OV = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);

OV.createSession()
.then(session => {

// Generate a new token
session.generateToken(tokenOptions)
.then(token => {

// Return the Token to the client
res.status(200).send({
0: token
});

session.fetch().then(anyChange => {
console.log('FETCHED');
});
})
.catch(error => {
console.error(error);
});
})
.catch(error => {
console.error(error);
});

Pablo

unread,
Dec 10, 2019, 6:42:13 AM12/10/19
to OpenVidu
In the first line I made a mistake. Obviously I was refering to "Session.fetch" method, not "Session.fetched"

Beka Iglesias López

unread,
Dec 12, 2019, 5:27:47 PM12/12/19
to Pablo, OpenVidu
Thanks a lot for the answer. Ok, I can get it inside OV.createSession() too. I can access OV.fetch() inside different controllers for different endpoints as /api-sessions to get all the active Sessions without any problem. I can't access session.fetch() in controllers for endpoints as /api-sessions/{sessionId} to get the active connections or for banning one connection. This is the normal behaviour or it would possible access both fetch in the same way?

--
You received this message because you are subscribed to the Google Groups "OpenVidu" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openvidu+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openvidu/e2825dfd-96fc-45b3-a685-1e7794131383%40googlegroups.com.

Pablo

unread,
Dec 13, 2019, 7:34:31 AM12/13/19
to OpenVidu
This is not a problem with openvidu-node-client library. This is a problem with the way you are managing your variables in your Node code. I haven't seen it, but if you are able to execut an object's method in some part of your code but you can't in other parts, then make sure your Session objects lifecycle makes sense and that they are properly defined in all the methods you are accessing them.

Beka Iglesias López

unread,
Dec 13, 2019, 7:35:42 AM12/13/19
to Pablo, OpenVidu
Perfect.Thanks for the answer

El vie., 13 dic. 2019 a las 13:34, Pablo (<pablofue...@gmail.com>) escribió:
This is not a problem with openvidu-node-client library. This is a problem with the way you are managing your variables in your Node code. I haven't seen it, but if you are able to execut an object's method in some part of your code but you can't in other parts, then make sure your Session objects lifecycle makes sense and that they are properly defined in all the methods you are accessing them.

--
You received this message because you are subscribed to the Google Groups "OpenVidu" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openvidu+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages