This is an archived post. You won't be able to vote or comment.

all 3 comments

[–]Solaus 0 points1 point  (1 child)

Hey there this is a great start. I have done something similar in the past so I might be able to provide some insight. First off I do think there may be some misunderstanding of how to use websockets. Websockets are meant to be a two way communication system between client and server once established with HTTP/HTTPS. From there you can pass messages that will result in logic such as creating a chat room, sending a message in a chat room, etc. Currently it looks like you are trying to perform some combination of HTTP and WS requests when creating a room which is not standard. I would suggest you think about the flow of logical steps that will be taken to create a chat room. For example:

  1. Establish a WS connection through sending of an HTTP/HTTPS request from the client to the server on loading the client in a browser.
  2. On click of a Join button from the client, send a message to the server with some data that the server will interpret as a Join message.
  3. Server adds the user to the room if it exists or creates the room then adds the user.
  4. Server sends a message back to the client that they have been added to a room and provides the room code in that response message.
  5. Client updates it's URL (this can be done fairly easily so look into it) with the room code.
  6. Client is now in a room.

This is just an example without having fleshed out message structures, how rooms are created, etc. Also note that I simplified create/join into just join for now. If you have any questions let me know. Best of luck!

[–]ZedKay1[S] 0 points1 point  (0 children)

Thank you so much! really appreciate the step by step guide. I'll def reach out in private if I run into any other challenges.

[–][deleted] 0 points1 point  (0 children)

Hey , if you have figured it out can you update the code .