简体   繁体   English

存储/记录来自socket.io的所有发射数据并回放

[英]Store/Record all emitting data from socket.io and playback

Lets take an example of Canvas Drawing. 让我们以“画布绘图”为例。 Source: http://wesbos.com/html5-canvas-websockets-nodejs/ 资料来源: http : //wesbos.com/html5-canvas-websockets-nodejs/

How can emitting data from socket.io be stored or recorded so that it can be played again? 如何存储或记录来自socket.io的数据,以便再次播放? For eg an artist sketches a drawing on above canvas, it should be recorded so that learners could see it again and again. 例如,一位艺术家在画布上绘制素描,则应将其记录下来,以便学习者可以一次又一次地看到它。

Is any library or module available which could help storing this data? 是否有任何可帮助存储此数据的库或模块? Is it better to save this data in files like xml or it should be stored in a database like Redis? 最好将这些数据保存在xml之类的文件中,还是应该将其存储在Redis之类的数据库中? To play this data, it has to be stored with time info. 要播放此数据,必须将其与时间信息一起存储。

UPDATE 1 更新1
Found a perfect example. 找到了一个完美的例子。
http://draw.2x.io/replay.html#/history/flodge/9236932481660473952/play http://draw.2x.io/replay.html#/history/flodge/9236932481660473952/播放
It seems (from tweets) that above site uses redis and mongodb. 从推文中可以看出,以上站点使用redis和mongodb。

Answering my own question, I am not sure if it is correct approach. 在回答我自己的问题时,我不确定这是否正确。

From example below. 从下面的示例。 It uses animate button to replay recorded session. 它使用动画按钮重播录制的会话。
http://code.google.com/p/html-5-canvas-whiteboard/ http://code.google.com/p/html-5-canvas-whiteboard/

It looks like it is possible to store complete recording as an object within browser memory. 看起来可以将完整的记录作为对象存储在浏览器内存中。
Same object will be built on server (in memory itself). 将在服务器上(在内存本身中)构建相同的对象。
Once recording session is complete it can be stored in database. 录制会话完成后,可以将其存储在数据库中。

During playback, object from database can be retrieved in single request. 在回放期间,可以在单个请求中检索数据库中的对象。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM