Implementing WebSocket Client and Server on ASP.NET Core 6 | HOW TO - Code Samples

Поделиться
HTML-код
  • Опубликовано: 21 авг 2024
  • StartupHakk.co...
    #coding #codingbootcamp #softwaredeveloper #CodeYourFuture
    GitHub Repo: github.com/slt...
    Websocket is a protocol that enables seamless communication between clients and servers over a single, long-lived connection. Unlike traditional web communication methods like HTTP, which follows a request-response model, WebSockets introduce a full-duplex communication channel. This means that both the client and server can send and receive data simultaneously, allowing for instant updates and real-time interaction.
    WebSockets are commonly used in scenarios requiring real-time data updates. Examples of such situations include a multiplayer game’s lobby chat, real-time notifications, stock market data feeds, and live collaboration tools. These applications necessitate instantaneous communication and data exchange, something that WebSockets adeptly provides.
    However, while WebSockets bring significant advantages, they do require specific server-side support. The server needs to implement a WebSocket server that adheres to the WebSocket protocol. This protocol includes handling incoming connections, managing client sessions, and routing messages between connected clients.
    In this video, we will implement a WebSocket server and client in .NET 6.0 with C#
    With the WebSocket instance, we can check the connection State with ws.State. Here are the possible values of WebSocketState
    1. None
    2. Connecting: The connection is negotiating the handshake with the remote endpoint.
    3. Open: Initial state after the HTTP handshake has been completed.
    4. CloseSent: Close message was sent to the client.
    5. CloseReceived: Close message was received from the client.
    6. Closed: Close handshake completed gracefully.
    7. Aborted: The connection is aborted.
    In this video, we have explored the basics of WebSocket, discussed how to create both a WebSocket server and client, and shown how to handle common tasks such as sending and receiving messages, handling connection aborts, and broadcasting messages to all connected clients.
    We’ve seen how this technology is a game-changer for real-time applications, allowing for seamless, bidirectional communication between clients and servers. This is expressed in our implementation of the real-time chat application.
    Lots of Great How Tos and Code Samples! Make sure to like and subscribe!

Комментарии • 22

  • @ritwikgupta7540
    @ritwikgupta7540 8 месяцев назад +15

    I see what you are doing there...with the accent

    • @STARTUPHAKK_sh
      @STARTUPHAKK_sh  8 месяцев назад

      What do you mean?

    • @abdirizakjamalismail6672
      @abdirizakjamalismail6672 7 месяцев назад +6

      lmao, don't let him get away with it.

    • @CleanTechnology
      @CleanTechnology 7 месяцев назад

      @@abdirizakjamalismail6672 😆

    • @marquardtsnell7916
      @marquardtsnell7916 Месяц назад

      I don't get it. I mean, I can hear some kind of accent, but I can't tell what it's supposed to be or why it's necessary.

  • @nine9winged
    @nine9winged 26 дней назад +2

    Using a light theme = -200 Aura. But the tutorial is so good that you get +20000 Aura

    • @STARTUPHAKK_sh
      @STARTUPHAKK_sh  26 дней назад +1

      @@nine9winged thanks!

    • @the-boss-98
      @the-boss-98 12 дней назад +2

      See the thing is dark mode was not that popular before 10 years ago, thats why a lot of og devs still use light theme because thats what they are used to.

    • @STARTUPHAKK_sh
      @STARTUPHAKK_sh  12 дней назад +2

      @@the-boss-98 Funny - I consider myself a super old-school / OG developer ... and I have been using dark theme for as long as I can remember. :)

    • @the-boss-98
      @the-boss-98 12 дней назад +1

      @@STARTUPHAKK_sh Really? then why on video u are having light mode🤔

    • @STARTUPHAKK_sh
      @STARTUPHAKK_sh  12 дней назад +1

      @@the-boss-98 lol. This is one of our instructors doing this video. I have since taken over making all of the videos with their help but he was recording these when we made the videos a few months back

  • @kevinnguyen3845
    @kevinnguyen3845 8 месяцев назад +1

    thanks ❤❤❤❤

    • @STARTUPHAKK_sh
      @STARTUPHAKK_sh  8 месяцев назад

      Thanks! Make sure to subscribe! We bring lots of awesome videos!

  • @bogomildonkov6477
    @bogomildonkov6477 6 месяцев назад +1

    how to run multiple instances of the application ?

    • @STARTUPHAKK_sh
      @STARTUPHAKK_sh  6 месяцев назад

      Thanks for watching this video. You can use the concept of Threading for running multiple instances.

  • @duongtruongvu
    @duongtruongvu 7 месяцев назад +1

    can you guide me how to implement with wss? thanks

    • @STARTUPHAKK_sh
      @STARTUPHAKK_sh  7 месяцев назад

      This video should be a good video for it.

  • @user-ui8cc9yf4m
    @user-ui8cc9yf4m 3 месяца назад +1

    is this will workout for web api??

    • @STARTUPHAKK_sh
      @STARTUPHAKK_sh  3 месяца назад +1

      We think so. We have done more updated videos on this subject with .NET 8 to bring it to latest: ruclips.net/video/8qDRWvffGLQ/видео.html