使用ajax创建在线实时文本编辑器

时间:2022-08-26 18:40:12

I am going to make a realtime text editor,

我要做一个实时文本编辑器,

after my research, I understood that google doc is using javascript and quite hard for a non-experience student to do this kind of application.

在我的研究之后,我明白了谷歌doc使用的是javascript,对于一个没有经验的学生来说,做这种应用是非常困难的。

And i found that there is another editor perform similiarly:

我发现还有另外一个编辑在做类似的工作:

http://collabedit.com/

http://collabedit.com/

So the problem is, it this implement base on java script or using other more easier approach? I would like to do some editor like that one and i don't need any syntax check . just allow multi- users input font at real time and notify who typing the word, thats all.

问题是,这个实现是基于java脚本还是使用其他更简单的方法?我想做一些像那样的编辑器,我不需要任何语法检查。只要允许多用户实时输入字体,并通知谁输入这个词,仅此而已。

1)Can i do this by ajax?

1)我可以用ajax实现吗?

2) What function i can use to do that?

2)我能用什么函数来做?

Thank you.

谢谢你!

2 个解决方案

#1


2  

What you're describing is a bit beyond the functionality of AJAX and enters into a slightly more advanced model known as COMET (which may or may not include the facilities of WebSockets depending on who you ask).

您所描述的有点超出了AJAX的功能,并进入了稍微高级一点的模型COMET(根据您的要求,COMET可能包含也可能不包含WebSockets的功能)。

More or less, Comet allows bi-directional communication between the web page and the server. This means the client is able to post notifications to the server and the server is able to push notifications to any of its clients. A good framework that abstracts this for you is Socket.IO.

Comet或多或少允许web页面与服务器之间的双向通信。这意味着客户端能够向服务器发送通知,而服务器能够向任何客户端推送通知。一个好的框架可以为您抽象这一点,那就是Socket.IO。

The next thing you'll need to address is the back end. You'll need a server side application that tracks who is connected so you can collect changes (new text from each user) and post those changes to the other listeners (the other users participating in the text editing session). While you may be able to use PHP, C#, etc. to accomplish this, I would personally recommend you take some time to learn node.js as it is engineered to specifically handle this kind of realtime multi-user application.

接下来需要处理的是后端。您将需要一个服务器端应用程序来跟踪连接的用户,以便您可以收集更改(每个用户的新文本)并将这些更改发布到其他侦听器(参与文本编辑会话的其他用户)。虽然您可能可以使用PHP、c#等来实现这一点,但我个人建议您花一些时间学习node。它被设计成专门处理这种实时多用户应用程序。

Lastly, I have a similar answer to another post here that may help you further.

最后,我有一个类似的回答,这里的另一个帖子可能会帮助你进一步。

#2


1  

For what you want to achieve, you may be better off using HTML5's new WebSockets. They use a much smaller overhead, and were made for extended, continuous connections.

对于您想要实现的目标,您最好使用HTML5的新WebSockets。它们使用的开销要小得多,并且用于扩展的、连续的连接。

http://websocket.org/quantum.html

http://websocket.org/quantum.html

#1


2  

What you're describing is a bit beyond the functionality of AJAX and enters into a slightly more advanced model known as COMET (which may or may not include the facilities of WebSockets depending on who you ask).

您所描述的有点超出了AJAX的功能,并进入了稍微高级一点的模型COMET(根据您的要求,COMET可能包含也可能不包含WebSockets的功能)。

More or less, Comet allows bi-directional communication between the web page and the server. This means the client is able to post notifications to the server and the server is able to push notifications to any of its clients. A good framework that abstracts this for you is Socket.IO.

Comet或多或少允许web页面与服务器之间的双向通信。这意味着客户端能够向服务器发送通知,而服务器能够向任何客户端推送通知。一个好的框架可以为您抽象这一点,那就是Socket.IO。

The next thing you'll need to address is the back end. You'll need a server side application that tracks who is connected so you can collect changes (new text from each user) and post those changes to the other listeners (the other users participating in the text editing session). While you may be able to use PHP, C#, etc. to accomplish this, I would personally recommend you take some time to learn node.js as it is engineered to specifically handle this kind of realtime multi-user application.

接下来需要处理的是后端。您将需要一个服务器端应用程序来跟踪连接的用户,以便您可以收集更改(每个用户的新文本)并将这些更改发布到其他侦听器(参与文本编辑会话的其他用户)。虽然您可能可以使用PHP、c#等来实现这一点,但我个人建议您花一些时间学习node。它被设计成专门处理这种实时多用户应用程序。

Lastly, I have a similar answer to another post here that may help you further.

最后,我有一个类似的回答,这里的另一个帖子可能会帮助你进一步。

#2


1  

For what you want to achieve, you may be better off using HTML5's new WebSockets. They use a much smaller overhead, and were made for extended, continuous connections.

对于您想要实现的目标,您最好使用HTML5的新WebSockets。它们使用的开销要小得多,并且用于扩展的、连续的连接。

http://websocket.org/quantum.html

http://websocket.org/quantum.html