客户端-服务器通信协议的架构决策
这个问题实际上很普遍,但我真的很难找到一个好的答案或如何完成它的例子。
我们正在编写一个简单的多用户协作 Web 浏览应用程序,但在决定使用什么通信协议时遇到了一些问题。 我们正在 Mono 下使用 C# 进行开发,希望最终能够实现跨平台。
通信可能包含以下消息:在会话上注册为用户(客户端到服务器)、通知客户端连接的新用户(服务器到客户端)、请求页面加载(客户端到服务器)等。 到目前为止,我们的想法是:
- 基本 Message 类的扩展的 XmlSerialization
我们一直在尝试,但在使用 XmlSerialization 机制作为及时传递数据的方法时遇到了困难,因此我们有 进行二进制序列化的正确方法,
- 怀疑这是在相同情况下
我不太喜欢这种方法,因为数据采用的形式,而且我担心它的风险更大。
Google Protocol Buffers
WCF
两者听起来都更接近应该使用的内容,但我们担心对于这样一个非常简单的协议来说这有点过分了。
可能还有我错过的其他人。
什么是一个干净的好方法来做到这一点?
This question is pretty generic actually, but I'm really having trouble finding a good answer or example of how it should be done.
We are writing a simple multi-user collaborative web browsing application and we are having some issues deciding what to use for a communication protocol.
We are developing in C# under Mono, hoping to eventually make it cross-platform.
The communication would probably consist of messages such as: registering as a user on a session (client to server), notifying clients of a new user who connected (server to clients), requesting a page load (client to server), etc.
The ideas we have so far are:
- XmlSerialization of extensions of a base Message class
which we have been trying but are having trouble using the XmlSerialization mechanism as a means of passing data in time, so we're having doubts it's a right way to do this
- Binary serialization in the same case
which I don't really like because of the form the data takes, and because I'm afraid it's a bit more risky.
Google Protocol Buffers
WCF
both of which sound much closer to what should be used, but we're afraid it would be overkill for such a quite simple protocol.
and possibly others that I've missed.
What would be a good clean way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WCF——给你一个平台。
然后将 JSON 和 REST 用于实际 API(您可以在 WCF 中使用的选项)。这样你基本上就可以“原生”地使用 javascript 工作了。
WCF 是一个很棒的工具(遗憾的是,大多数单声道可能落后太多 - 不确定),包括为服务器端接口动态生成 javascript 代理。
WCF - gives you a platform.
THen use JSON and REST for the actual API (options you can use in WCF). This way you can basically "natively" work in javascript.
WCF is great tool wise (sadly, mono most may be too much behind for most of it - not sure), including generating javascript proxies on the fly for your server side interfaces.