How to get Chat Name from Websocket?


  • Plugin & Theme Dev

    It looks like this is the websocket method i want to call, but i can't seem to get a response out of it....

    i/ve tried socket.emit('modules.chats.getRoomData', 1576, function(){console.log(arguments)}) in chrome's console and gotten nothing, even though room 1576 shows up when i execute socket.emit('modules.chats.getRecentChats', {after:0}, function(){console.log(arguments)})

    Can someone point me in the right direction here?


  • Admin

    Not all methods are available to sockets. Try

    socket.emit('modules.chats.loadRoom', {roomId: 1576}, callback);

    You won't be able to get any data if the user making the call is not in the room.


  • Plugin & Theme Dev

    @baris said in How to get Chat Name from Websocket?:

    Not all methods are available to sockets

    ah. that brings me to my next questio..... oh nevermind. loadRooms does give me the users in the room.

    @baris said in How to get Chat Name from Websocket?:

    socket.emit('modules.chats.loadRoom', {roomId: 1576}, callback);

    got it!

    and that's got the data i wanted.

    now to figure out if there's a way to load a chat message by message id, or if that's just going to have to be a "you need to iterate through the chats for that" thing.

    you wouldn't happen to know that one off the top of your head would you? :cute_fox_eyes:

    @baris said in How to get Chat Name from Websocket?:

    You won't be able to get any data if the user making the call is not in the room.

    that's fine. it gives me an error on a "bad" room which is what i want anyway. ;-)


  • Admin

    There is a method to get the raw content of a message by its message id but there is no method to load all the data of a message yet.


  • Plugin & Theme Dev

    @baris said in How to get Chat Name from Websocket?:

    There is a method to get the raw content of a message by its message id

    interestingly so does sockbot although i recon the two different methods serve rather different purposes. ;-)

    @baris said in How to get Chat Name from Websocket?:

    there is no method to load all the data of a message yet.

    ah. trhen my interface shall throw E_UNSUPPORTED for now until a certain vixen makes a PR to fix that. ;-)


Log in to reply
 

Looks like your connection to NodeBB was lost, please wait while we try to reconnect.