示例#1
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();
    }
示例#2
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;
     }
 }