Skip to content

Commit

Permalink
Add RealtimeApi::socket() to access the underlying network socket
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed Nov 2, 2024
1 parent 2393b36 commit 9543b46
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ OpenAI APIs for XP ChangeLog

## ?.?.? / ????-??-??

* Added `RealtimeApi::socket()` to access the underlying network socket
(@thekid)
* Merged PR #17: Move the `Tools` class to the com.openai.tools package
(@thekid)

Expand Down
3 changes: 3 additions & 0 deletions src/main/php/com/openai/realtime/RealtimeApi.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public function __construct($endpoint) {
});
}

/** @return peer.Socket */
public function socket() { return $this->ws->socket(); }

/** @param ?util.log.LogCategory $cat */
public function setTrace($cat) {
$this->cat= $cat;
Expand Down
6 changes: 6 additions & 0 deletions src/test/php/com/openai/unittest/RealtimeApiTest.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use com\openai\realtime\RealtimeApi;
use lang\IllegalStateException;
use peer\Socket;
use test\{Assert, Expect, Test, Values};

class RealtimeApiTest {
Expand All @@ -26,6 +27,11 @@ public function initially_not_connected() {
Assert::false($c->connected());
}

#[Test]
public function socket_accessor() {
Assert::instance(Socket::class, (new RealtimeApi(self::URI))->socket());
}

#[Test]
public function connect() {
$c= new RealtimeApi(new TestingSocket([self::SESSION_CREATED]));
Expand Down

0 comments on commit 9543b46

Please sign in to comment.