设计 C# 服务器来处理独立于平台的数据?
我正在考虑设计一个可以在多个平台(即Windows、Macintosh、Android、iPhone)上运行的应用程序,但所有平台都与在一台中央服务器上存储和处理的数据进行交互。
基本上: 服务器托管世界状态 - 包括活动客户端、它们在世界中的实体以及从该实体的角度渲染世界的规则。 客户端持有对该实体的引用,并向服务器发送请求以更新其状态并根据其实体检索渲染。
我最擅长的语言是 C#,所以我更喜欢用它来编写服务器。
我知道我需要开发自己的命令语法,该语法可以由服务器解释并对所有客户端通用。我不太了解服务器编码的实际实现,只了解必要的高级概念。
.Net 套接字 API 是否可用于非 .Net 套接字客户端?这是一个有效的问题吗?
基本上我想知道如何最好地以结构化方式发送和接收数据,但这种方式独立于平台。
请求所需的数据示例类似于
实体:[实体名称]
RequestType:[请求类型](假设它是一个操作命令)
动作类型:[动作类型]
ActionProp1:[操作属性]
.
。
或
实体:[实体名称]
RequestType:[请求类型](可以说请求渲染)
RenderDimX:[渲染的 X 维度]
RenderDimY:[渲染的 Y 维度]
我实际上还没有计划出请求语法,所以不要批评:)
这只是我想要从客户端发送到服务器的消息类型。
那么如何设置 C# 服务器来处理将发送这些类型消息的客户端呢?或者我对这一切都错了?
谢谢!
I am looking into designing an application that can run on multiple platforms (i.e. windows, macintosh, android, iphone) but which all interact with data stored and processed on one central server.
Basically:
The server hosts state of world - including active clients, their entity within the world, and rules for rendering the world from the perspective of that entity.
Clients hold a reference to that entity and send requests to the server to update its state and retrieve the renderings based on their entity.
My strongest language above all is C# so I would prefer to write the server using that.
I know that I will need to develop my own sort of command syntax that can be be interpreted by the server and be universal to all clients. What I don't know is much of anything about the practical implementation of coding the server, just the high-level idea of what is necessary.
Is the .Net sockets API usable with non-.Net socket clients? Is that even a valid question?
Basically I would like to know how best to send and receive data in a structured way, but a way that is independent of platform.
A sample of the data needed for a request would be something like
Entity: [Entity Name]
RequestType: [Request Type] (Lets say its an action command)
ActionType: [Action Type]
ActionProp1: [Action Property]
.
.
or
Entity: [Entity Name]
RequestType: [Request Type] (Lets say request render)
RenderDimX: [X Dimension of Render]
RenderDimY: [Y Dimension of Render]
I haven't actually planned out the request syntax yet, so don't criticize :)
This is just the kind of message I want to be sending from client to server.
So how do I set up a C# server to handle clients that will be sending these types of messages? Or am I going about this all wrong?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不提供基于 REST 的服务并通过这些服务提供一切可用的服务?以 HTML / XML / 等形式提供,任何客户端都应该能够连接、查询和使用发回的数据。对于听起来像软件即服务模型的套接字级别的编程似乎有点过分了。
Why not do REST based services and have everything available through those? Served up as HTML / XML / etc., any client should be able to connect, query, and use the data sent back. Programming at the socket level seems a bit much for what sounds like a software as a service model.
我最终使用了套接字。标准化协议使其变得相当容易。
I ended up using sockets. The standardized protocols made it fairly easy.