相关文章推荐
瘦瘦的猴子  ·  python numpy ...·  7 月前    · 
傲视众生的电脑桌  ·  vue ...·  11 月前    · 
火爆的凳子  ·  TypeError: ...·  1 年前    · 
满身肌肉的领带  ·  Cellulose ...·  1 年前    · 
微笑的松球  ·  javascript - How to ...·  2 年前    · 
ClientWebSocket ws = new ClientWebSocket(); CancellationToken ct = new CancellationToken(); //添加header //ws.Options.SetRequestHeader("X-Token", "eyJhbGciOiJIUzI1N"); Uri url = new Uri("ws://121.40.165.18:8800/v1/test/test"); await ws.ConnectAsync(url, ct); await ws.SendAsync(new ArraySegment(Encoding.UTF8.GetBytes("hello")), WebSocketMessageType.Binary, true, ct); //发送数据 while (true) var result = new byte[1024]; await ws.ReceiveAsync(new ArraySegment(result), new CancellationToken());//接受数据 var str = Encoding.UTF8.GetString(result, 0, result.Length); Debug.Log(str); catch (Exception ex) Console.WriteLine(ex.Message);