Skip to content

Commit

Permalink
PubNub SDK v4.5.0 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
client-engineering-bot committed Aug 24, 2021
1 parent c78612a commit 49d2fb0
Show file tree
Hide file tree
Showing 21 changed files with 484 additions and 117 deletions.
10 changes: 8 additions & 2 deletions .pubnub.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
name: php
version: 4.4.0
version: 4.5.0
schema: 1
scm: github.com/pubnub/php
changelog:
- version: v4.5.0
date: Aug 24, 21
changes:
-
text: "Missing PNPresenceEventResult getters added, dependency update."
type: feature
- version: v4.4.0
date: Jul 29, 21
date: 2021-07-29
changes:
-
text: "Fix for wrong signature calculation mechanism added."
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [v4.5.0](https://github.com/pubnub/php/releases/tag/v4.5.0)
August-24-2021

- 🌟️ Missing PNPresenceEventResult getters added, dependency update.

## [v4.4.0](https://github.com/pubnub/php/releases/tag/v4.4.0)
July-29-2021

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ You will need the publish and subscribe keys to authenticate your app. Get your

## Configure PubNub

1. Integrate the Java SDK into your project:
1. Integrate the PHP SDK into your project:

* Without composer

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"keywords": ["api", "real-time", "realtime", "real time", "ajax", "push"],
"homepage": "http://www.pubnub.com/",
"license": "MIT",
"version": "4.4.0",
"version": "4.5.0",
"authors": [
{
"name": "PubNub",
Expand Down
36 changes: 24 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/PubNub/Callbacks/SubscribeCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ abstract function message($pubnub, $message);

// TODO: add annotation
abstract function presence($pubnub, $presence);

// Not marked as abstract for backward compatibility reasons.
function signal($pubnub, $signal) {}
}
156 changes: 156 additions & 0 deletions src/PubNub/Endpoints/PubSub/Signal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?php

namespace PubNub\Endpoints\PubSub;

use PubNub\Endpoints\Endpoint;
use PubNub\Enums\PNHttpMethod;
use PubNub\Enums\PNOperationType;
use PubNub\Exceptions\PubNubBuildRequestException;
use PubNub\Exceptions\PubNubValidationException;
use PubNub\Models\Consumer\PubSub\PNSignalResult;
use PubNub\PubNubUtil;

class Signal extends Endpoint
{
const SIGNAL_PATH = "/signal/%s/%s/0/%s/0/%s";

/** @var mixed $message to send the signal */
protected $message;

/** @var string $channel to send message on*/
protected $channel;

/**
* @param mixed $message
* @return $this
*/
public function message($message)
{
$this->message = $message;

return $this;
}

/**
* @param string $channel
* @return $this
*/
public function channel($channel)
{
$this->channel = $channel;

return $this;
}

/**
* @throws PubNubValidationException
*/
protected function validateParams()
{
if ($this->message === null) {
throw new PubNubValidationException("Message Missing");
}

if (!is_string($this->channel) || strlen($this->channel) === 0) {
throw new PubNubValidationException("Channel Missing");
}

$this->validateSubscribeKey();
$this->validatePublishKey();
}

/**
* @return string
* @throws PubNubBuildRequestException
*/
protected function buildPath()
{
$stringifiedMessage = PubNubUtil::writeValueAsString($this->message);

return sprintf(
static::SIGNAL_PATH,
$this->pubnub->getConfiguration()->getPublishKey(),
$this->pubnub->getConfiguration()->getSubscribeKey(),
PubNubUtil::urlEncode($this->channel),
$stringifiedMessage
);
}


protected function buildData()
{
return [];
}

protected function customParams()
{
return [];
}

/**
* @return PNPublishResult
*/
public function sync()
{
return parent::sync();
}

/**
* @param array $json Decoded json
* @return PNPublishResult
*/
protected function createResponse($json)
{
$timetoken = floatval($json[2]);

return new PNSignalResult($timetoken);
}

/**
* @return bool
*/
protected function isAuthRequired()
{
return true;
}

/**
* @return int
*/
protected function getRequestTimeout()
{
return $this->pubnub->getConfiguration()->getNonSubscribeRequestTimeout();
}

/**
* @return int
*/
protected function getConnectTimeout()
{
return $this->pubnub->getConfiguration()->getConnectTimeout();
}

/**
* @return string
*/
protected function httpMethod()
{
return PNHttpMethod::GET;
}

/**
* @return int
*/
protected function getOperationType()
{
return PNOperationType::PNSignalOperation;
}

/**
* @return string
*/
protected function getName()
{
return "Signal";
}
}
4 changes: 3 additions & 1 deletion src/PubNub/Enums/PNOperationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,6 @@ class PNOperationType
const PNGetMembershipsOperation = 37;
const PNSetMembershipsOperation = 38;
const PNRemoveMembershipsOperation = 39;
}

const PNSignalOperation = 40;
}
11 changes: 11 additions & 0 deletions src/PubNub/Managers/ListenerManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use PubNub\Exceptions\PubNubUnsubscribeException;
use PubNub\Models\Consumer\PubSub\PNMessageResult;
use PubNub\Models\Consumer\PubSub\PNPresenceEventResult;
use PubNub\Models\Consumer\PubSub\PNSignalMessageResult;
use PubNub\Models\ResponseHelpers\PNStatus;
use PubNub\PubNub;

Expand Down Expand Up @@ -79,4 +80,14 @@ public function announcePresence(PNPresenceEventResult $presence)
$listener->presence($this->pubnub, $presence);
}
}
/**
* @param PNSignalMessageResult $presence
* @throws PubNubUnsubscribeException
*/
public function announceSignal(PNSignalMessageResult $signal)
{
foreach ($this->listeners as $listener) {
$listener->signal($this->pubnub, $signal);
}
}
}
Loading

0 comments on commit 49d2fb0

Please sign in to comment.