Skip to content

Commit

Permalink
Update implementing_socket_io.md
Browse files Browse the repository at this point in the history
Just following orders
  • Loading branch information
archessmn authored Oct 18, 2024
1 parent ea88ac6 commit 0b4cfee
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion docs/development/implementing_socket_io.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function UpdatedValue(props: { initialValue: string }) {

## Server example

To send a message from the server to the client, import `io` from `@/lib/socket/server` and use it like a regular [socket server instance](https://socket.io/docs/v4/server-socket-instance/) to emit messages. Ideal usage is to create a helper function in `@/lib/socket/server` such as `socketUpdateSignupSheet()` in `@/lib/socket/server/signUpSheet.ts`. This is so that the exact implementation can be reused between nextjs and the socket server if needed.
To send a message from the server to the client, import `io` from `@/lib/socket/server` and use it like a regular [socket server instance](https://socket.io/docs/v4/server-socket-instance/) to emit messages. The way you should do it unless you have a very good reason not to is to create a helper function in `@/lib/socket/server` such as `socketUpdateSignupSheet()` in `@/lib/socket/server/signUpSheet.ts`. This is so that the exact implementation can be reused between nextjs and the socket server if needed.

**actions.ts** (Next.js server action)

Expand Down

0 comments on commit 0b4cfee

Please sign in to comment.