如何在不重新加载页面的情况下通过服务器推送动态更新HTML5画布?

What I would like to do is create a canvas that will show a network map. It's not really a network map but in terms of explaining it the network map example works best to not bog you down with details that don't pertain to my question.

On the network map I want to display routes the traffic takes. These routes change in time, sometimes as frequently as multiple times per minute. On the server side I have a log file to which each route change is appended as it happens.

I know how to create the canvas, I know how to draw my routes onto the canvas.

Is it possible to have the server push an update to the canvas without requiring a page reload/refresh, essentially requiring no user interaction at all? The routes drawn just automagically change?

This would need to work on IIS so a jscript or .Net based solution would be necessary. I won't be able to install PHP, Python, Ruby etc.

Thanks in advance for any insights you can provide.

#0

I recommend that you look at a WebSockets solution to push the information from the server to the client (JavaScript). When you receive the update you can update the canvas as required.

Technologies you should look at if your preferred server technology is .NET would be a service like Pusher, who I work for, and our .NET APIs which let you push updates to the client via our REST API.

If you would prefer to host your own realtime infrastructure then you could look at WebSync (which is actually a Comet technology) which integrates with IIS and also XSockets. There are also a number of realtime technologies on this guide which may interest you. If you've any further questions just let me know.

#1

Server-Sent Events: http://www.html5rocks.com/en/tutorials/eventsource/basics

( Server-sent events is a technology for providing push notifications from a server to a browser client in the form of DOM events. The Server-Sent Events EventSource API is now being standardized as part of HTML5[1] by the W3C. )

#2

Yes, I've done this before (with an ajax-based drawing application). It's very possible. Send packets of information via AJAX (JSON or something), interpret them, and draw them on the client's canvas element. This is trivial to design (and easy to implement using something like jQuery). It seems that you already figured out you need to have a server-side script that pushes information to a web page and a web page that actually draws stuff on the canvas. That's essentially all it is.

推荐文章

mod_rewrite不工作

mod_rewrite不工作

推荐文章

关联模型的activerecord查找条件

关联模型的activerecord查找条件

推荐文章

XSL,使用XML作为模板的参数

XSL,使用XML作为模板的参数

推荐文章

非AJAX网站上下文中的命令模式示例

非AJAX网站上下文中的命令模式示例

推荐文章

定义颜色值和可绘制标记之间的区别?

定义颜色值和可绘制标记之间的区别?

推荐文章

创建通用CsvReader

创建通用CsvReader

推荐文章

Magento XMLRPC API使用finset运算符失败

Magento XMLRPC API使用finset运算符失败

推荐文章

打印一个页面的打印url?

打印一个页面的打印url?

推荐文章

如何通过UDP发送实时数据?

如何通过UDP发送实时数据?

推荐文章

处理异常不是更好的办法吗

处理异常不是更好的办法吗

推荐文章

只从bash中的wc获取整数

只从bash中的wc获取整数

推荐文章

同一域但不同文件夹上的多个symfony项目

同一域但不同文件夹上的多个symfony项目

推荐文章

多次调用时,setApplicationBadgeNumber不会更新徽章

多次调用时,setApplicationBadgeNumber不会更新徽章

推荐文章

在C++中初始化结构的2维数组

在C++中初始化结构的2维数组

推荐文章

PHP:匹配regex数组的行

PHP:匹配regex数组的行

推荐文章

更新放置在UITableViews节头中的UILabel的值

更新放置在UITableViews节头中的UILabel的值