Skip to content

Commit 800a52b

Browse files
author
amin
committed
fix dependencies on the root package issue
1 parent e5d1299 commit 800a52b

File tree

6 files changed

+67
-10
lines changed

6 files changed

+67
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# WebRTC Data Channel Implementation
22

33
[![PHP Version](https://img.shields.io/badge/php-8.4%2B-blue.svg)](https://php.net/)
4-
[![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
4+
[![License](https://img.shields.io/badge/license-BSD-blue.svg)](LICENSE)
55

66
A PHP implementation of WebRTC's RTCDataChannel interface for bidirectional peer-to-peer data communication.
77

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"require": {
2626
"php": "^8.4",
2727
"quasarstream/exception": "^1.0",
28-
"quasarstream/sctp": "^1.0",
2928
"psr/log": "^3.0"
3029
},
3130
"require-dev": {

src/RTCDataChannel.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Webrtc\DataChannel\Enum\State;
1717
use Webrtc\Exception\InvalidArgumentException;
1818
use Webrtc\Exception\RuntimeException;
19-
use Webrtc\SCTP\RTCSctpTransport;
2019

2120
/**
2221
* Represents a bidirectional peer-to-peer data channel for WebRTC communications.
@@ -42,7 +41,7 @@ class RTCDataChannel extends EventEmitter implements RTCDataChannelInterface
4241
private ?int $id;
4342
private RTCDataChannelParameters $parameters;
4443
private State $readyState = State::Connecting;
45-
private RTCSctpTransport $transport;
44+
private RTCSctpTransportInterface $transport;
4645
private bool $sendOpen;
4746
private ?LoggerInterface $logger = null;
4847

@@ -53,13 +52,13 @@ class RTCDataChannel extends EventEmitter implements RTCDataChannelInterface
5352
* - For in-band: Automatically initiates the opening procedure
5453
* - For out-of-band: Verifies ID validity and registers with transport
5554
*
56-
* @param RTCSctpTransport $transport The SCTP transport layer for data transmission
55+
* @param RTCSctpTransportInterface $transport The SCTP transport layer for data transmission
5756
* @param RTCDataChannelParameters $parameters Configuration parameters for the channel
5857
* @param bool $sendOpen Whether to immediately send open request (for in-band)
5958
* @throws InvalidArgumentException If negotiated channel has invalid ID
6059
*/
6160
public function __construct(
62-
RTCSctpTransport $transport,
61+
RTCSctpTransportInterface $transport,
6362
RTCDataChannelParameters $parameters,
6463
bool $sendOpen = true
6564
)
@@ -234,9 +233,9 @@ public function getReadyState(): State
234233
/**
235234
* Gets the underlying SCTP transport.
236235
*
237-
* @return RTCSctpTransport The transport instance
236+
* @return RTCSctpTransportInterface The transport instance
238237
*/
239-
public function getTransport(): RTCSctpTransport
238+
public function getTransport(): RTCSctpTransportInterface
240239
{
241240
return $this->transport;
242241
}

src/RTCSctpTransportInterface.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/**
4+
* This file is part of the PHP WebRTC package.
5+
*
6+
* (c) Amin Yazdanpanah <https://www.aminyazdanpanah.com/#contact>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Webrtc\DataChannel;
13+
14+
interface RTCSctpTransportInterface
15+
{
16+
public function dataChannelOpen(RTCDataChannel $channel): void;
17+
18+
public function dataChannelAddNegotiated(RTCDataChannel $channel): void;
19+
20+
public function dataChannelClose(RTCDataChannel $channel): void;
21+
22+
public function onReceived(string $data): void;
23+
24+
public function onErrorOrClosed(): void;
25+
}

tests/RTCDataChannelTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Webrtc\tests;
3+
namespace Tests\Webrtc\DataChannel;
44

55
use PHPUnit\Framework\Attributes\CoversClass;
66
use PHPUnit\Framework\Attributes\UsesClass;
@@ -11,7 +11,6 @@
1111
use Webrtc\DataChannel\RTCDataChannelParameters;
1212
use Webrtc\Exception\InvalidArgumentException;
1313
use Webrtc\Exception\RuntimeException;
14-
use Webrtc\SCTP\RTCSctpTransport;
1514

1615
#[UsesClass(RTCDataChannelParameters::class)]
1716
#[CoversClass(RTCDataChannel::class)]

tests/RTCSctpTransport.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Tests\Webrtc\DataChannel;
4+
5+
use Webrtc\DataChannel\RTCDataChannel;
6+
use Webrtc\DataChannel\RTCSctpTransportInterface;
7+
8+
class RTCSctpTransport implements RTCSctpTransportInterface
9+
{
10+
11+
public function onReceived(string $data): void
12+
{
13+
// TODO: Implement onReceived() method.
14+
}
15+
16+
public function onErrorOrClosed(): void
17+
{
18+
// TODO: Implement onErrorOrClosed() method.
19+
}
20+
21+
public function dataChannelOpen(RTCDataChannel $channel): void
22+
{
23+
// TODO: Implement dataChannelOpen() method.
24+
}
25+
26+
public function dataChannelAddNegotiated(RTCDataChannel $channel): void
27+
{
28+
// TODO: Implement dataChannelAddNegotiated() method.
29+
}
30+
31+
public function dataChannelClose(RTCDataChannel $channel): void
32+
{
33+
// TODO: Implement dataChannelClose() method.
34+
}
35+
}

0 commit comments

Comments
 (0)