Giter Club home page Giter Club logo

chitchat's Introduction

Socket IO practice

Something to showcase socket IO usage in action.

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).

chitchat's People

Contributors

stacksharebot avatar aim97 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.