Skip to content

Commit

Permalink
some fancy markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
aim97 committed Jun 3, 2023
1 parent 5209af8 commit 99a4d08
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Basics/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Simple ChitChat

This is a simple chat made with Socket IO, the client automatically generates an ID for the user, and uses it during its current session.

It's made as a simple demo for the most basic features of socket IO so little to no security measures are taken into consideration.
19 changes: 17 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Socket IO practice

This is a simple chat made with Socket IO, the client automatically generates an ID for the user, and uses it during its current session.
Something to showcase socket IO usage in action.

It's made as a simple demo for the most basic features of socket IO so little to no security measures are taken into consideration.
## Basic server workflow

- You start by creating an instance of Socket IO server, it can be connected to an http server you created like done here, or working on its own.
- Socket io is event driven so the flow is mainly driven by the `on(eventName, handler)` function, that simply handle and event with a given name, by a given function.
- And the most important event is the `connection` event that's where you
- identify the client
- Add them into a room
- set the events of interest of that client to keep it updated with messages on those events that are meant for them.
- There is surely authentication in socket IO, its data is sent from the client and is accessible from `handshake` field of the socket. for security it's passed on the `auth` field inside it.
- We may add a middleware on a socket server using the `use` function, similar to express. except it takes `socket`, and `next` as inputs, but works intuitively enough as you'd expect, if not pay a visit for the docs.

## Basic client workflow

- Similarly, you would create a socket io client that connects to the server providing the credentials in the options if required.
- Then the client would provide handler for the events its interested to listen on.
- The client can also send messages using the `emit` function (actually similarly can the server).

0 comments on commit 99a4d08

Please sign in to comment.