Giter Site home page Giter Site logo

chatroom's Introduction

running this service

  • pip install reflex
  • reflex init
  • reflex run

chatroom

A multi-client chat room.

broadcast_event

This function iterates through all states in the app, applying the Event payload against each state instance. The resulting change list is passed off to pynecone.app.EventNamespace.emit() directly.

Either event handlers or other out-of-band callbacks can use this API to emit Events from the server as if they originated from the client. This preserves the simple State and Event Handler conceptual model, while allowing server-to-client communication and state updates at will.

send_message

broadcast_event is used in the send_message event handler, which broadcasts the state.incoming_message event to all connected clients, with the details of the message. This in itself doesn't trigger any network traffic, unless the state update creates a delta.

nick_change

When the user sets or changes their nick, the event handler first updates the local state, as usual. Then it awaits, broadcast_nicks which collects the full nick list from the State instance of each connected client by iterating over app.state_manager.states values.

The same broadcast_event mechanism described above is then used to pass the nick list via the state.set_nicks event to all connected clients.

chatroom's People

Contributors

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