[英]Multi-device architecture
I'm at the moment trying to make up a "core" for my multi-device project.我目前正在尝试为我的多设备项目构建一个“核心”。
The project is all about a web application, that authenticates the user by facebook login, and then exposes a set of new actions they can do - ex.该项目是关于 web 应用程序的,该应用程序通过 facebook 登录对用户进行身份验证,然后公开他们可以执行的一组新操作 - 例如。 Get all records in the database thats related to their facebook id etc.
获取数据库中与其 facebook id 等相关的所有记录。
The core should be understood by following devices:核心应该通过以下设备来理解:
Now how would you make up the core?现在你将如何组成核心?
Would you make it a WCF service that returns JSON?您是否将其设为返回 JSON 的 WCF 服务?
Would you make it a bunch of Controllers that returns JSON?你会把它变成一堆返回 JSON 的控制器吗?
And how would you ensure that the user is who he/she says, when querying the core?在查询核心时,您如何确保用户是他/她所说的人? Should I pass along the accessToken thats generated by facebook each time?
我应该每次传递 facebook 生成的 accessToken 吗?
As you might have noticed, I've absolutely no idea at all how to do this.正如您可能已经注意到的那样,我完全不知道如何做到这一点。
Thanks in advance.提前致谢。
Not sure if I understand your question correctly, but...不确定我是否正确理解了您的问题,但是...
First, you will have to define, or probably decide , what the "Core" is?首先,您必须定义或可能决定“核心”是什么? or what the Core should be - what will be the functionality that
Core
will perform.或者核心应该是什么——
Core
将执行什么功能。 Ideally, when we say Core, it essentially means, a layer that performs basic or atomic operations .理想情况下,当我们说核心时,它本质上是指执行基本或原子操作的层。
Over that Core you can spawn the device wrappers(IPhone, PC, etc) that builds a query to be sent to core, for instance.例如,通过该核心,您可以生成构建查询以发送到核心的设备包装器(iPhone、PC 等)。
You can use WCF Data Service to constitute a data layer.您可以使用 WCF 数据服务来构成数据层。 And your core can perform business operations/etc, and communicate with the Data Service.
您的核心可以执行业务操作/等,并与数据服务通信。
For instance, what I instantly can think of is:例如,我立即能想到的是:
DeviceWrapper
( DeviceAndriod, DeviceIPhone, DeviceWeb, etc ), that wraps different devices. DeviceWrapper
( DeviceAndriod、DeviceIPhone、DeviceWeb 等),用于包装不同的设备。 For example, a mixture of Factory/Builder pattern.Device
s, and Builder for types of views.Device
的工厂,以及视图类型的 Builder。TextRenderer
, based upon the device settings, renders the text. TextRenderer
根据设备设置呈现文本。 One way could be, lets decide:一种方法可能是,让我们决定:
The Core
, will be a "library" that will perform basic operations: Core
将是一个执行基本操作的“库”:
Therefore,所以,
STEP 1 : Write a Controller that will provide authenticate/authorization;第 1步:编写 Controller 以提供身份验证/授权; for instance, call the
Core.Authenticate()
, and Authorize()
;例如,调用
Core.Authenticate()
和Authorize()
;
STEP 2 : Based upon the user agent call ICore.RenderView(agentType), this may return you the view/html to be rendered.第 2步:基于用户代理调用 ICore.RenderView(agentType),这可能会返回要呈现的视图/html。
User may perform an action, your Controller may call Core.PerformAction()
;用户可以执行一个动作,你的 Controller 可以调用
Core.PerformAction()
; which in turn may return the link to the page to be redirected, for instance.例如,这反过来可能会将链接返回到要重定向的页面。
--UPDATED-- - 更新 -
This update is in response to your comment.此更新是为了回应您的评论。
Now, in this(your comment) case, you are talking about client ends.现在,在这个(您的评论)案例中,您正在谈论客户端。
Lets clear up a bit.让我们澄清一下。 There is server and there are client sides.
有服务器,也有客户端。
Up till now, we were talking about Server side, which primarily is concerned with:到目前为止,我们讨论的是服务器端,主要涉及:
Client ends could be:客户端可能是:
Decide what this "client app" will do.决定这个“客户端应用程序”将做什么。 For instance, in your case:
例如,在您的情况下:
Note that, you may want to consider smart clients (using web services, rather than asp.net web pages).请注意,您可能需要考虑智能客户端(使用 web 服务,而不是 asp.net web 页面)。
Also, the type hinting in WCF can add a lot of unnecessary overhead in the JSON response for large collections.此外,WCF 中的类型提示可能会在 JSON 响应中为大型 collections 添加大量不必要的开销。 Therefore, if you even remotely believe that you might want multiple types of end-points (SOAP, etc.) at some point in the time, then WCF is the way to go.
因此,如果您甚至认为您可能在某个时间点需要多种类型的端点(SOAP 等),那么 WCF 就是通往 go 的方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.