// Start is called before the first frame update
    void Start()
    {
        uri = new Uri(urlString);
        Debug.Log(QuicheVersion.GetVersion());
        QuicheDebug.EnableDebugLogging((line, argp) => {
            Debug.Log(line);
        });
        client = new UdpClient();

        var config = new QuicheConfig(0xbabababa);

        byte[] protos = Encoding.ASCII.GetBytes("\x05hq-24\x05hq-23\x08http/0.9");
        config.SetApplicationProtos(protos);
        config.SetIdleTimeout(5000);
        config.SetMaxPacketSize(QuicheClient.MAX_DATAGRAM_SIZE);
        config.SetInitialMaxData(10000000);
        config.SetInitialMaxStreamDataBidiLocal(1000000);
        config.SetInitialMaxStreamDataUni(1000000);
        config.SetInitialMaxStreamsBidi(100);
        config.SetInitialMaxStreamsUni(100);
        config.SetDisableActiveMigration(true);
        config.VerifyPeer(false);
        quiche = new QuicheClient(config);
        Connect();
    }
 void OnDestroy()
 {
     if (conn != null)
     {
         conn.Dispose();
         conn = null;
     }
     if (quiche != null)
     {
         quiche.Dispose();
         quiche = null;
     }
     if (client != null)
     {
         client.Dispose();
         client = null;
     }
 }
Example #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();
    }
Example #4
0
 void OnDestroy()
 {
     if (h3Conn != null)
     {
         h3Conn.Dispose();
         h3Conn = null;
     }
     if (h3Config != null)
     {
         h3Config.Dispose();
         h3Config = null;
     }
     if (quicheClient != null)
     {
         quicheClient.Dispose();
         quicheClient = null;
     }
     if (udpClient != null)
     {
         udpClient.Dispose();
         udpClient = null;
     }
 }