handleWorkerPayload handles the payload received by a worker. If payload is
valid it is echoed back to all workers except the worker that it was received
from.
@param  {String} payload Payload received from a worker.
554299
function handleWorkerPayload (payload) {
  // Parse and validate received payload.
  if ((payload = utils.parsePayload(payload)) === null) return

  // If the master is configured to echo events to its own master, the event
  // emitted by the worker should be echoed to the master.
  if (this.__echoEvents === true) {
    const echoPayload = JSON.parse(JSON.stringify(payload))
    // Update PID as if the payload is originating from this process, the master
    // is in. If this is not done, the master of this process, will resend the
    // payload since the PID is different.
    echoPayload[fields.pid] = process.pid
    process.send(echoPayload)
  }

  // Unmarshal args.
  payload[fields.args] = marshaller.unmarshal(payload[fields.args])

  // Notify instance listeners.
  events.prototype.emit.call(this, payload[fields.event],
    ...payload[fields.args])

  // Notify all workers except the worker who emitted the event.
  sendPayload.call(this, payload)
}
354855
private function handleHeartbeatResponse()
    {
        $state = $this->worker->getState();
        if (Worker::BUSY == $state) {
            /**
             * We should only reply in the following cases:
             * - A heartbeat is about to expire.
             * - We have a result.
             */
            return;
        }

        if (Worker::RESULT_AVAILABLE == $state) {
            // A result is available send it to the worker handler.
            $this->handleResult();

            return;
        }

        if (in_array($state, array(Worker::READY, Worker::RESULT, Worker::REGISTER))) {
            // Update the state to ready and forget about the last job.
            $this->worker->cleanup();

            // Request a new job
            $this->sendToWorkerHandler(new GetJobRequest());

            return;
        }

        if (Worker::SHUTDOWN != $state) {
            // The worker did not request a shutdown, however all other states should be handled at this point.
            $this->getLogger()->error('Invalid worker state: '.$this->worker->getState().'.');
        }

        // Worker is completely shutdown, because there is no open connection to the worker handler.
        $this->worker->setState(Worker::INVALID);
    }
679724
function fixEventPayload(events) {
    return new Promise(function (resolve, reject) {
        events.forEach(function(event) {
            try {
                event.payload = JSON.parse(event.payload);
            } catch (e) {
                console.log('Could not parse payload');
                return reject(new Error('Could not parse payload: ' + e.message));
            }
        });
        resolve();
    });
}
230370
function handleChallenge(ws, challenge){
	console.log('handleChallenge');
	if (ws.bLoggingIn)
		sendLoginCommand(ws, challenge);
	else // save for future login
		ws.received_challenge = challenge;
}
14809
function (context, payload) {
        var state = context.state;
        var entity = state.$name;
        // If the payload is an array, then the payload should be an array of
        // data so let's pass the whole payload as data.
        if (Array.isArray(payload)) {
            return context.dispatch(state.$connection + "/update", { entity: entity, data: payload }, { root: true });
        }
        // If the payload doesn't have `data` property, we'll assume that
        // the user has passed the object as the payload so let's define
        // the whole payload as a data.
        if (payload.data === undefined) {
            return context.dispatch(state.$connection + "/update", { entity: entity, data: payload }, { root: true });
        }
        // Else destructure the payload and let root action handle it.
        return context.dispatch(state.$connection + "/update", __assign({ entity: entity }, payload), { root: true });
    }
424427
function (payload) {
        var pendingList = pendings[payload.type];
        if (pendingList) {
            pendingList.push(payload);
        }
        else {
            payload.dispatchAction = dispatchAction;
            api.dispatchAction(payload);
        }
    }
243360
public function handle($payload)
    {
        $data = json_decode($payload, true) ?: [];
        $events = (array)@$data['events'];
        $results = [];

        try {
            foreach ($events as $event) {
                $input = $this->captureInput($event);
                $command = $this->registry->findCommand($input);
                $command->input = $input;

                $results[] = $this->commandBus->handle($command);
            }
        } catch (DerailException $e) {
            $results[] = $this->handler->handle($e->command);
        } catch (\Exception $e) {
            $results[] = sprintf('ERROR: %s', $e->getMessage());
        }

        return $results;
    }
1297105
public void sendPayload(String payload) {
		MessageEnvelope envelope = new MessageEnvelope();
		Postback postback = new Postback();

		postback.setPayload(payload);
		envelope.setPostback(postback);
		envelope.setSender(new User(facebookMockId));

		System.out.println("Sending payload: [" + payload + "] as user : ["
				+ facebookMockId + "].");
		forward(envelope);
		System.out.println("Sent!");
	}
937419
protected function handleJobRequest(
        string $clientAddress,
        string $jobName,
        string $payload = '',
        bool $backgroundJob = false
    ) : string {
        $jobId = $this->addJobToQueue($jobName, $payload);
        $this->jobTypes[$jobId] = ($backgroundJob === true) ? 'background' : 'normal';
        $this->jobAddresses[$jobId] = $clientAddress;
        $this->pushJobs();
        if ($backgroundJob === true) {
            $this->respondToClient($clientAddress, $jobId);
        }
        $this->totalJobRequests++;
        return $jobId;
    }
900126
public function pushRaw($payload, $queue = null, array $options = [])
    {
        $payload = (new JobPayload($payload))->prepare($this->lastPushed)->value;

        return tap(parent::pushRaw($payload, $queue, $options), function () use ($queue, $payload) {
            $this->event($this->getQueue($queue), new JobPushed($payload));
        });
    }
704753
def rpcexec(self, payload):
        
        log.debug(json.dumps(payload))
        self.ws.send(json.dumps(payload, ensure_ascii=False).encode("utf8"))
1051917
public function onData(Payload $payload)
    {
        $this->received[] = $payload;
        if (($callback = $this->options['on_data_callback'])) {
            call_user_func($callback, $payload);
        }
    }
406642
function handleMessage(m, workerIdx) {
	var job = jobs[m.context.jobID];

	switch(job.type) {
		case 'func':
			handleArrayResult(m, workerIdx);
			break;
		case 'exec':
			handleExecResult(m, workerIdx);
			break;
		default:
			throw Error('Invalid job type: ' + job.type);
	}
}
1211398
private void sendNextPayload() {
		singleThreadExecutor.execute(new Runnable() {
			@Override
			public void run() {
				try {
					sendNextPayloadSync();
				} catch (Exception e) {
					ApptentiveLog.e(e, "Exception while trying to send next payload");
					logException(e);
				}
			}
		});
	}
1059688
public function triggerEvent($event, Payload $payload)
    {
        if ($payload->state() === null) {
            $this->updatePayload($this->process->initialState(), $payload);
        }

        $state = $this->process->state($payload->state());

        $nextStateName = $state->triggerEvent($event, $payload);
        if ($nextStateName === null) {
            return;
        }

        $state = $this->process->state($nextStateName);

        $this->updatePayload($state, $payload);
        $this->handleOnStateWasSet($state, $payload);
    }
149524
function handlePushError(pushError, pushHandler) {
    return Platform.async(function(callback) {
        callback();
    })().then(function() {
        
        if (pushError.isConflict()) {
            if (pushHandler && pushHandler.onConflict) {
                // NOTE: value of server record will not be available in case of 409.
                return pushHandler.onConflict(pushError);
            }
        } else if (pushHandler && pushHandler.onError) {
            return pushHandler.onError(pushError);
        }

    }).then(undefined, function(error) {
        // Set isHandled to false even if the user has set it to handled if the onConflict / onError failed 
        pushError.isHandled = false;
    });
}
810884
public function completed(JobPayload $payload, $failed = false)
    {
        if ($payload->isRetry()) {
            $this->updateRetryInformationOnParent($payload, $failed);
        }

        $this->connection()->pipeline(function ($pipe) use ($payload, $failed) {
            $this->markJobAsCompleted($pipe, $payload->id(), $failed);
        });
    }