Jump to content

Need help on programming a real-time chat application using PHP WebSocket


Recommended Posts

Posted (edited)

Hi, I'm creating a social media with a real-time chat application using PHP WebSocket, the basic functionalities are working properly but I need to implement some other features as well. So I need help with the following related to the chat application:

  1. Login to the WebSocket using the credentials users use to log into the social media.
  2. Allow users to chat with their friends only.
  3. Identify users from the database using their ID and fetch data from the database.
  4. Show online/offline status based on the WebSocket.
  5. Show if a message is pending/sent/delivered/seen status.
  6. Show typing notification to the other user.

I'm attaching a screenshot of the chat screen:

image.thumb.png.5201a746609b23040bf424b4983150d5.png

Edited by sagnik
Added another reason
Link to comment
Share on other sites

  • 2 weeks later...

Logins via social media are usually done using OAuth and OpenID Connect, which can be non-trivial to implement. For development purposes, as long as you're just testing on your own computer, I'd recommend building a mock login flow that just takes a username. It would be far too insecure to expose to the public Internet, but it would give you an opportunity to work out your database layer, which will be required for OAuth anyway.

Link to comment
Share on other sites

Thanks for the advice, but the service has its login service, which uses SSO but the problem is handling the sessions within the WebSocket server for multiple clients.

Link to comment
Share on other sites

  • 2 weeks later...

First of all, sorry about the slow response. I was expecting to get a notification e-mail, but it turns out that I needed to adjust my settings for that to happen.

So, it sounds like you've got an external SSO provider of some kind. Is it based on OAuth/OpenID Connect or on some other SSO protocol? For OAuth, if you have access to self-encoded access tokens, those can be relatively straightforward to validate without having to track too much session-related state in your own database. Since you mentioned social media logins, I'm going to guess they probably do use self-encoded access tokens since that's common for services that operate at a very large scale.

For the database layer, is there already a specific database you're looking at using?

Link to comment
Share on other sites

OK, if you've already got SSO sorted out, is your first question about how to handle authentication specifically when you're opening the WebSocket connection?
 

On 5/23/2024 at 7:37 AM, sagnik said:

Login to the WebSocket using the credentials users use to log into the social media.

Edited by Haradion
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...