如何在强模式下将HtmlWebSocketChannel强制转换为StreamChannel <string>?

时间:2017-12-04 20:11:28

标签: dart dart-dev-compiler

我尝试使用标准的json_rpc_2 pub包连接到DDC 1.24.2上的Chrome 62中的json_rpc服务器。我是在https://github.com/dart-lang/json_rpc_2#client找到基于客户端的示例。

该示例在分析阶段(1)失败。似乎是最好的修复在运行时失败(2)。

var socket = new HtmlWebSocketChannel.connect(address);
// (1) analysis error: The argument type 'HtmlWebSocketChannel' can't be assigned to the parameter type 'StreamChannel<String>'
_client = new json_rpc.Client(socket);
// (2) runtime error: found = "HtmlWebSocketChannel" expected = "StreamChannel<String>", type = class StreamChannel
_client = new json_rpc.Client(socket.cast<String>());

解决方案似乎应该很简单,但我没有看到\发现它。任何帮助表示赞赏。谢谢!

更新12/5/2017

而不是Chromium(Da​​rtVM)中的运行时错误,我们得到了无限的挂起。看着我能看到的网络流量,它从来没有发过任何东西。我无法获得任何示例代码来运行他们的回购。

我在socket / HtmlWebSocketChannel上运行了一些测试,我得到了来回发送纯文本消息。

所以,我刚刚推出了自己的json rpc客户端。这使得原始问题得不到解决,但问题中使用的库除此之外似乎还有其他问题。这并没有真正使这个问题无效,我会把它留在这里以防万一。

0 个答案:

没有答案