基于WebSocket和SenchaTouch的移动Web应用设计与实现
2014-07-13吕海东
摘要:移动Web应用迅猛发展,对系统的响应速度要求更高,同时要降低数据传输量,以便减少话费支出。传统的Web HTTP工作模式,由于在请求和响应中附加大量数据,难以满足移动用户需求。该文结合了移动Web框架Sencha Touch和WebSocket技术,设计实现了全新模式的移动Web应用,克服了普通Web的缺点,提升了系统的性能。
关键词: Sencha Touch; WebSocket; Spring; Hibernate
中图分类号:TP393.09 文献标识码:A 文章编号:1009-3044(2014)05-0942-04
Mobile Web App Designing and Implementing Based on Sencha Touch and WebSocket
LV Hai-dong
(City Institute Dalian University of Technology, Dalian 116600, China)
Abstract: With the rapid development of mobile Web application, the response speed of the system requirements are higher, at the same time to reduce the amount of data transmission, in order to reduce the cost of expenditure. In traditional Web HTTP mode, due to additional amounts of data in the request and response, it is unable to meet the needs of mobile users. This paper combines the mobile Web framework Sencha Touch and WebSocket technology, design and implementation of mobile Web application of new mode, overcomes the drawbacks of conventional Web, improving system performance.
Key words: Sencha Touch; WebSocket; Spring; Hibernate
随着智能手机和平板电脑的普及,移动Web开发成为发展最快的领域,各种移动Web框架如雨后春笋层出不穷,Sencha Touch就是众多框架中的佼佼者。它是基于HTML 5的移动应用JavaScript框架,可以让Web 应用界面模拟原生应用。其具有优美用户界面组件和丰富的数据管理,完全使用标准HTML 5和CSS3,全面兼容Android,iOS及其他移动设备。Sencha Touch与其他移动框架比较,是个较重量级的移动Web应用框架,由于其对触摸屏丰富的UI设计,支持用戶复杂交互,并使用纯JavaScript实现页面元素布局,因此适合用于开发业务逻辑比较复杂的移动Web应用,如交互较多的OA系统,ERP管理系统等。
但在与服务器端的数据交互过程中,Sencha Touch依然使用传统的HTTP请求响应模式的AJAX技术,难以实现数据的快速响应和显示。由于每次AJAX的HTTP请求和响应中依然包含大量重复的头信息,致使数据传输量增加,不但降低应用的响应速度,而且会导致用户话费的损失以及手机电源的损耗。
HTML5的WebSocket规范的提出,将彻底取代现有的AJAX技术,抛弃了原有Web应用的请求/响应模式,取而代之的是客户和服务器的双向实时数据传输,极大提高了数据传输效率,使得移动Web应用可以与原生应用相媲美。……
