GithubHelp home page GithubHelp logo

Comments (2)

curiosity26 avatar curiosity26 commented on July 27, 2024

The Bayuex client takes care of it all for you. You only need to create the client, add the extensions you want, subscribe a consumer to a channel and then start the client.

Here's a quick example:

<?php

$streamingClient = new BayeuxClient(
            new LongPollingTransport(),
            new OAuthProvider(
                getenv("SF_CLIENT_ID"),
                getenv("SF_CLIENT_SECRET"),
                getenv("SF_LOGIN_URL"),
                getenv("SF_USER"),
                getenv("SF_PASS")
            )
        );

$streamingClient->addExtension(new ReplayExtension(ReplayExtension::REPLAY_SAVED));

// Creates a new channel with the client if one does not exist already
$channel = $streamingClient->getChannel('/topic/Accounts');
// Subscribe a consumer to the channel
$channel->subscribe(
       Consumer::create(
            function (ChannelInterface $channel, Message $message) {
                $data = $message->getData();
                $sobject = $data->getSobject();

                // Do something with the object

                $replayId = $data->getEvent()->getReplayId();
            }
      )
);

// When you start the client, all defined channels make a subscribe call to Salesforce after the handshake
// When the channel receives a message from Salesforce, all consumers that have subscribed
// to the channel are fired in order of their priority
// This will run forever or until you stop it
$streamingClient->start();

from salesforce-rest-sdk.

RileyDavidson avatar RileyDavidson commented on July 27, 2024

I have a similar question. If I want to manually specify the Replay ID, I seem to not able to do this. Can you advise? I assumed $channel->addExtension(new ReplayExtension(<REPLAY_ID_HERE>)); would work.

from salesforce-rest-sdk.

Related Issues (20)

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.