您是如何构建面向网络的应用程序的? [英] How have you structured your network oriented apps?

查看:27
本文介绍了您是如何构建面向网络的应用程序的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开始设计一个主要面向网络的新应用,我正在寻求一些提出良好架构设计或 OOP 类模型的人的建议.

I'm starting the design of a new app that is primarily network oriented, and I'm looking for some advice from people who have come up with a good architectural design, or OOP class model.

请描述基本架构和/或类结构.你抽象出通信位了吗?你想出了哪些类实体?

Please describe the basic architecture and/or class structure. Did you abstract out the communication bits? What class entities did you come up with?

该应用程序将同时具有侦听器和客户端类.它类似于提要聚合器,但使用持久连接而不是 HTTP.换句话说,我连接到一个套接字并有一个持久连接,数据在其中双向流动.然后我也有客户端持续连接到我,我将部分(或全部)数据发送给他们.

The app will have both listener and client classes. It's similar to a feed aggregator, but uses persistent connections rather HTTP. In other words, I connect to a socket and have a persistent connection in which data flows both ways. Then I also have clients that connect to me persistently and i send some (or all) of the data to them.

此外,我不能使用 WCF 或 .NET 3.0 或 3.5 中的任何内容(尽管我可以使用 C# 3,因为我是在 VS2008 上开发的).我必须与 Windows 2000 兼容.

Also, I can't use WCF or anything that's in .NET 3.0 or 3.5 (though I can use C# 3 because i'm developing on VS2008). I have to be compatible with Windows 2000.

推荐答案

我正处于几周前开始编写的客户端-服务器应用程序的尾端.我将 WCF 用于 .Net cient &服务器.

I am on the tail end of a client-server app that I started writing a few weeks ago. I used WCF for the .Net cient & server.

但是服务器还必须连接到网络上只能通过 TCP/IP 识别 ASCII 的设备.

But the server also had to connect to a device on the network that only understood ASCII over TCP/IP.

你是否抽象出通信位?

是的.我猜.我的意思是,我不确定我是否 100% 理解你的问题.对于与第 3 方设备的 TCP 连接,我将 TCP 连接和通信的详细信息隐藏在我编写的类后面.该设备将 ASCII 命令转换为 IR 信号,以控制卫星天线和 DVD 播放器等设备.我将 TCP 通信抽象为一个类,因此我的服务器所要做的就是进行如下调用:

Yes. I guess. I mean, I am not sure I understand your question 100%. For my TCP connection to the 3rd party device I hid the details of the TCP connection and communication behind a class I wrote. The device in question converts ASCII commands to IR signals to control things like satellite dishes and DVD players. I abstracted the TCP communication into a class so all my server had to do is make a call like:

_irService.SendCommand(someAsciiCommand);

你想出了哪些类实体?

它们基于我的域.您的域名应该基于您的域名.我不确定我是否理解除此之外的问题.您的域将决定您的对象.

They were based on my domain. Yours should be based on whatever your domain is. I am not sure I understand that question beyond that. Your domain is going to dictate your objects.

在我的域中,我正在处理一个服务器应用程序,该应用程序负责使用 VLC 通过 UDP 安排和播放多播广播.这些多播广播必须在各个方面都是可配置的.

In my domain I was dealing with a server application that was in charge of scheduling and playing multicast broadcasts over UDP utilizing VLC. These multicast broadcasts had to be configurable in every aspect.

当我分析域时,我想出了一个由广播、频道、设备和广播进程(负责启动 vlc.exe 进程并维护其生命周期的类)组成的模型.

When I analyzed the domain I came up with a model that consisted of Broadcasts, Channels, Devices and BroadcastProcesses (a class that was in charge of starting a vlc.exe process and maintaining its lifecycle).

域对网络技术影响不大.我最终在 WCF 中获得了一些双工服务",它们允许我操纵域.但是网络选择不是由域决定的.我想要一个对我的对象进行二进制序列化的 TCP 连接,我想要与服务器进行双向通信,以便我的客户端可以通过回调获得实时更新.无论我的域是什么样子,我都可以使用这些选项.

The domain had little impact on the networking technology. I ended up with a few duplex "services" in WCF that allowed me to manipulate the domain. But the networking choices were not dictated by the domain. I wanted a TCP connection with binary serialization of my objects, and I wanted a two-way communication with the server so my clients could get real-time updates via callbacks. Those options were available to me regardless of what my domain looked like.

这篇关于您是如何构建面向网络的应用程序的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆