private void Connect()
    {
        var host = uri.Host;
        var port = uri.Port;

        client.Connect($"{host}", port);
        conn = quiche.Connect(uri.Authority);
        Debug.Log(
            $"connecting to {uri.Authority} from {client.Client.LocalEndPoint} "
            + $"with scid {quiche.HexDump}");
        // initial send
        buf = new byte[QuicheClient.MAX_DATAGRAM_SIZE];
        int write = conn.Send(buf);

        client.Send(buf, write);
    }
 void OnDestroy()
 {
     if (conn != null)
     {
         conn.Dispose();
         conn = null;
     }
     if (quiche != null)
     {
         quiche.Dispose();
         quiche = null;
     }
     if (client != null)
     {
         client.Dispose();
         client = null;
     }
 }
示例#3
0
    // Start is called before the first frame update
    void Start()
    {
        uri = new Uri(urlString);
        Debug.Log(QuicheVersion.GetVersion());
        if (isDebugLog)
        {
            QuicheDebug.EnableDebugLogging((line, argp) => {
                Debug.Log(line);
            });
        }
        udpClient    = new UdpClient();
        quicheClient = new QuicheClient(CreateQuicheConfig());
        udpClient.Connect($"{uri.Host}", uri.Port);
        quicheConn = quicheClient.Connect(uri.Authority);
        Debug.Log(
            $"connecting to {uri.Authority} from {udpClient.Client.LocalEndPoint} "
            + $"with scid {quicheClient.HexDump}");
        // initial send
        int write = quicheConn.Send(buf);

        udpClient.Send(buf, write);

        h3Config = new H3Config();
        // Prepare request.
        var reqList = new H3Header[] {
            new H3Header(":method", "GET"),
            new H3Header(":scheme", "https"),
            new H3Header(":authority", uri.Host),
            new H3Header(":path", uri.PathAndQuery),
            new H3Header("user-agent", "unity-quiche"),
        }.ToList();

        // TODO Add custom headers to the request.

        // TODO Add body
        body = null;
        if (body != null)
        {
            reqList.Add(new H3Header(
                            "content-length", $"{body.Length}"));
        }
        req = reqList.ToArray();
    }
 public Client(QuicheConnection conn, IPEndPoint remoteIpEndPoint)
 {
     RemoteIpEndPoint = remoteIpEndPoint;
     Connection       = conn;
     PartialResponses = new Dictionary <ulong, PartialResponse>();
 }
 public H3Connection(QuicheConnection quicConn, H3Config config)
 {
     quicConnection = quicConn;
     conn           = NativeMethods.quiche_h3_conn_new_with_transport(
         quicConnection.Connection, config.Config);
 }