Skip to main content
 首页 » 编程设计

c#之Protobuf 消息平台是否独立

2024年02月13日16三少

我正在计划一个应用程序,其中服务器端将用 C# 编写,客户端将使用 phonegap 创建

该应用程序大量使用使用 protobuf-net 库序列化的二进制文件。

假设我在 C# 中有一个对象

public class Foo 
{ 
   private string FooProp; 
} 

并且此对象被序列化并使用 phonegap 传输到客户端。甚至可以反序列化 phone gap 中生成的二进制文件并使用 Javascript 在 phonegap 中访问这些属性吗?

请您参考如下方法:

the Protocol Buffers documentation的第一句是:

Welcome to the developer documentation for protocol buffers – a language-neutral, platform-neutral, extensible way of serializing structured data for use in communications protocols, data storage, and more.

因此,是的,protobuf 是独立于平台的。

至于你是否可以从 JavaScript 使用 protobuf,我会告诉你 this question ,因为总体答案似乎是“仅通过第三方库”。您还可以在 the protobuf project site 上找到一些第三方库。 .