Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.x] Added new events #91

Closed
wants to merge 4 commits into from
Closed

Conversation

michaelnabil230
Copy link
Contributor

@michaelnabil230 michaelnabil230 commented Mar 16, 2024

This PR introduces significant enhancements to events, providing developers with the capability to listen to a range of pivotal events, thereby facilitating more dynamic and interactive user experiences. Additionally, it's noteworthy that events do not block the event loop to close the connection, ensuring smooth operation and efficient resource management. Moreover, this PR assists developers in migrating from Soketi to Reverb, streamlining the transition process, and leveraging the enhanced event capabilities offered by Reverb. The following events are now accessible through this PR:

Events:

  1. NewConnection:

    • This event enables developers to track and handle new connections established within the application. It empowers them to execute specific actions or initialize processes upon a new client connection, enhancing overall control and management of interactions.
  2. ConnectionClosed:

    • Developers gain insight into connection terminations through the ConnectionClosed event. This visibility allows for graceful handling of connection closures, ensuring necessary cleanup tasks are performed to maintain application stability and reliability.
  3. ConnectionError:

    • The ConnectionError event notifies developers of connection errors during their lifecycle. By detecting these errors, developers can implement appropriate error-handling mechanisms promptly, improving the robustness and resilience of Laravel applications.
  4. SubscribedToChannel:

    • Signifying a client's successful subscription to a channel, the SubscribedToChannel event empowers developers to monitor subscription activities. They can execute custom logic or trigger additional actions tailored to specific user interactions, enhancing real-time messaging experiences.
  5. UnsubscribedFromChannel:

    • Conversely, the UnsubscribedFromChannel event indicates when a client unsubscribes from a channel. Developers can track these unsubscriptions and perform corresponding procedures, such as updating UI elements or performing cleanup tasks, ensuring efficient management of application resources and facilitating seamless user experiences.
  6. ServerStarted:

    • The ServerStarted event notifies developers when the server has started successfully. This event is crucial for executing tasks that should occur only after the server has fully initialized and is ready to handle incoming connections or requests.
  7. ServerStopped:

    • Conversely, the ServerStopped event indicates when the server has stopped. Developers can utilize this event to perform cleanup tasks or execute finalization procedures before the server completely shuts down, ensuring proper resource management and data integrity.

By incorporating these event functionalities, developers can unlock a myriad of possibilities for building dynamic, responsive, and engaging web applications. Whether it's real-time chat applications, live notifications, or collaborative features, this PR equips Laravel developers with the tools needed to craft immersive user experiences that keep users connected and informed in real-time.

@michaelnabil230 michaelnabil230 marked this pull request as draft March 16, 2024 20:08
@michaelnabil230 michaelnabil230 marked this pull request as ready for review March 16, 2024 21:22
@mpociot
Copy link

mpociot commented Mar 17, 2024

The main problem with these events is that even if dispatching the event might not block the event loop, any IO work that you do in the event listeners certainly will.
So introducing these events basically opens up the door to easily (without knowledge) block the event loop/websocket server.

@michaelnabil230 michaelnabil230 marked this pull request as draft March 17, 2024 20:03
@michaelnabil230
Copy link
Contributor Author

Hi @mpociot
Can you explain more, And from your point of view what is the correct way so that I can listen to an event?

@joedixon
Copy link
Collaborator

Thanks for the PR @michaelnabil230. However, right now, we want to keep events to a minimum to prevent users from unintentionally blocking the server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants