Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[讨论建议] 通过基于Swow\Socket 实现一个WebSocket 以及 HTTP2 客户端 #236

Open
itxiao6 opened this issue Dec 31, 2023 · 1 comment
Labels
discussion Discuss things in this issue

Comments

@itxiao6
Copy link

itxiao6 commented Dec 31, 2023

是否可以通过基于Swow\Socket 实现一个WebSocket 以及 HTTP2 客户端

如下示例

WebSocket Client

<?php
declare(strict_types=1);

namespace Swow\Client;

use Psr\Http\Message\UriInterface;
use Swow\Psr7\Message\WebSocketFrameInterface;

/**
 * Class WebSocket
 * @package Swow\Client
 */
class WebSocket
{
    /**
     * WebSocket constructor.
     * @param UriInterface $uri
     * @param array $options Headers 以及 SSL证书相关配置
     */
    public function __construct(UriInterface $uri, array $options = [])
    {

    }

    /**
     * 接收消息
     * @param int $timeout
     * @return WebSocketFrameInterface
     */
    public function receive(int $timeout = -1): WebSocketFrameInterface
    {

    }

    /**
     * 发送数据到服务
     * @param $data
     * @return bool
     */
    public function send($data): bool
    {

    }

    /**
     * 关闭连接
     * @return bool
     */
    public function close(): bool
    {
    }

}

HTTP2 Client

<?php
declare(strict_types=1);

namespace Swow\Client;

use Psr\Http\Message\UriInterface;
use Psr\Http\Message\MessageInterface;
/**
 * Class HTTP2
 * @package Swow\Client
 */
class HTTP2
{
    /**
     * WebSocket constructor.
     * @param UriInterface $uri
     * @param array $options Headers 以及 SSL证书相关配置
     */
    public function __construct(UriInterface $uri, array $options = [])
    {

    }

    /**
     * 接收消息
     * @param int $timeout
     * @return MessageInterface
     */
    public function receive(int $timeout = -1): MessageInterface
    {

    }

    /**
     * 关闭连接
     * @return bool
     */
    public function close(): bool
    {
    }

}
@itxiao6 itxiao6 added the discussion Discuss things in this issue label Dec 31, 2023
@dhermann6
Copy link

WebSocket 已经有实现了。http2这个有点复杂

@twose twose mentioned this issue May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discuss things in this issue
Projects
None yet
Development

No branches or pull requests

2 participants