论文标题
在打字稿中生成交互式WebSocket应用程序
Generating Interactive WebSocket Applications in TypeScript
论文作者
论文摘要
移动设备计算功率的进步使交互式Web应用程序成为可能,从而使Web浏览器能够动态渲染内容并支持与服务器的低延迟通信。这是为了给开发人员带来的代价,因为Web应用程序支持更复杂的通信模式,他们现在需要更多地推荐其应用程序中通信模式的正确性。 多方会话类型(MPST)提供了一个框架,以验证实现其规定的通信协议的一致性。现有的建议在应用程序开发中应用MPST框架要么忽略了Web应用程序的事件驱动性质,要么与行业工具和实践缺乏兼容性,这阻碍了Web开发人员的主流采用。 在本文中,我们介绍了MPST框架的实现,用于使用TypeScript和React.JS框架使用熟悉的行业工具来开发交互式Web应用程序。开发人员可以使用涂鸦协议语言指定协议,并使用涂鸦工具链来验证和获取每个角色的本地协议。本地协议描述了由角色观察到的全局通信协议的相互作用。我们将本地协议编码为打字稿类型,分别为服务器端和客户端目标提供餐饮。我们表明,我们的编码保证只有符合协议的实现才能键入检查。我们通过从游戏逻辑的MPST形式主义中对经典的Noughts和Cross Game进行基于网络的实现来证明我们的方法的有效性。
Advancements in mobile device computing power have made interactive web applications possible, allowing the web browser to render contents dynamically and support low-latency communication with the server. This comes at a cost to the developer, who now needs to reason more about correctness of communication patterns in their application as web applications support more complex communication patterns. Multiparty session types (MPST) provide a framework for verifying conformance of implementations to their prescribed communication protocol. Existing proposals for applying the MPST framework in application developments either neglect the event-driven nature of web applications, or lack compatibility with industry tools and practices, which discourages mainstream adoption by web developers. In this paper, we present an implementation of the MPST framework for developing interactive web applications using familiar industry tools using TypeScript and the React.js framework. The developer can use the Scribble protocol language to specify the protocol and use the Scribble toolchain to validate and obtain the local protocol for each role. The local protocol describes the interactions of the global communication protocol observed by the role. We encode the local protocol into TypeScript types, catering for server-side and client-side targets separately. We show that our encoding guarantees that only implementations which conform to the protocol can type-check. We demonstrate the effectiveness of our approach through a web-based implementation of the classic Noughts and Crosses game from an MPST formalism of the game logic.