tlaverdure / laravel-echo-server

Socket.io server for Laravel Echo
MIT License
2.65k stars 510 forks source link

Get All connected User List #150

Open dipit2007 opened 7 years ago

dipit2007 commented 7 years ago

I know socketio maintain database for all connected socketids and room database . does laravel-echo-server expose this info using any API or anything? I want to know how many and who are connected at a time. Please help.

barryvdh commented 7 years ago

https://github.com/tlaverdure/laravel-echo-server#http-api

dipit2007 commented 7 years ago

Thanks a lot. I was trying same but it was not working due to some silly mistake. Now Its working fine. Thanks a lot. One more query, is it possible to get this all info from laravel-echo-server using socket io interface? I mean I dont want to call API again and again but want to listen on certain event from server side to get all info through sockt io channel / communication. And obviously this channel and event only for Laravel Admin part not for others. Hope you got my point. Please help . Thanks .

jampack commented 7 years ago

i believe you must have to create a cron job and that will trigger the event time to time updating your cms/admin panel. It will be similar to hitting the api time to time.

dipit2007 commented 7 years ago

there are so many events when user get connected and disconnected and authorization is called etc. Why to create more event and make server burden to handle extra event? So, better to use existing events and make a separate admin channel to notify admin saying "Hey Admin, I have received New connection Socket ID is FAdfdFDFdaFDA", subsequently "Hey Admin, I am authorizing FAdfdFDFdaFDA from Server Now". Hope you have got my point.

dipit2007 commented 7 years ago

@barryvdh

I have found following code

**
     * On join a channel log success.
     *
     * @param {any} socket
     * @param {string} channel
     */
    onJoin(socket: any, channel: string): void {
        if (this.options.devMode) {
            Log.info(`[${new Date().toLocaleTimeString()}] - ${socket.id} joined channel: ${channel}`);
        }
}

Hope its starting point to modify to get what I need. Please guide me ..

jampack commented 7 years ago

as you said there can possibly be thousands on events per second. if you generate events from echo server itself that will overwhelm the event queue on laravel. What i actually meant was that make a cron job that runs every minute see and in the job trigger a laravel event that fetches the number of users by hitting the echo server api and emit the data to listeners, this way your front end will be updated every minute rather then numbers toggling madly on your frontend.

dipit2007 commented 7 years ago

Sorry to say.. you didn't get my point.. I am not talking about front end at all..

dipit2007 commented 7 years ago

I want one SPECIAL Channel which will be created during startup and will be accessible from restricted IP/HOST only. All log messages like when user get connected to a private,presence or public will be notified through this SPECIAL channel with proper / predefined event name.

This is required for admin real time dashboard for laravel-echo-server. Suppose someone is going to host it with daemon and also want monitor laravel-echo-server in real time.

I don't know about typescript. So help me to learn typescript to code and contribute on this.

May be this feature will be useful for others also.

Please help.

Thanks a lot.

dipit2007 commented 6 years ago

@tlaverdure Thanks for adding my requirement as feature. I want to contribute if possible. Please guide me so that I can write code for you.