Skip to content

Parallel and Concurrent processes for Bind events On Message #21

Open

Description

@sergioxdev

Hi Guys

I have been testing this package for a couple of days already, and I must say that it works well, my compliments to @binsoul

premise, I created a bot, which connects to a server brocker, this bot will receive messages from other clients, for each message operations will be performed and at the end the bot will send a message to the client.

I just have a problem with the following Bind to events: Incoming message
client-> on ('message', function (Message $ message) {
for ($ i ___ = 0; $ i ___ <50; $ i ___ ++) {
\ Log :: info ("For loop:". $ I ___. "- Device:");
sleep (1);
}
}

some incoming messages require some processing, therefore some waiting time, which I simulated with a simple for loop.

so far everything ok, the problem I encountered is that:

  • client_1, sends a message that requires a processing time of t_x seconds

  • client_2, sends a message that requires a processing time of t_y seconds

  • client_3, sends a message that requires a processing time of t_z seconds

  • at time t0 the bot receives and starts processing the message from client_1,

  • at time t1 the bot receives the message from client_2, but does not process it, because it still waits for the previous processing to finish and for the Bind to events to capture the new Incoming message,

  • at time t2 the bot receives the message from client_3, and will have to expand that all previous processing is completed

the library offers an asynchronous system, but not a parallel process, because in the end the processing of the Bind event (on message) is synchronous.

is there any way around this problem?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions