简体   繁体   English

多设备架构

[英]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:核心应该通过以下设备来理解:

  • PC个人电脑
  • IPhone苹果手机
  • Android Android
  • Windows Phone 7 Windows 电话 7

Now how would you make up the core?现在你将如何组成核心?

  1. Would you make it a WCF service that returns JSON?您是否将其设为返回 JSON 的 WCF 服务?

  2. Would you make it a bunch of Controllers that returns JSON?你会把它变成一堆返回 JSON 的控制器吗?

  3. 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:例如,我立即能想到的是:

  1. a Core, that performs core operations - for isntance talking to Datalayer一个核心,执行核心操作 - 例如与 Datalayer 交谈
  2. DeviceWrapper ( DeviceAndriod, DeviceIPhone, DeviceWeb, etc ), that wraps different devices. DeviceWrapperDeviceAndriod、DeviceIPhone、DeviceWeb 等),用于包装不同的设备。 For example, a mixture of Factory/Builder pattern.例如,Factory/Builder 模式的混合。 Think about factory of Device s, and Builder for types of views.想想Device的工厂,以及视图类型的 Builder。
  3. 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将是一个执行基本操作的“库”:

  • Authentication验证
  • Authorization授权
  • Select records Select 记录
  • Perform Action 1执行操作 1
  • Perform Action 2执行操作 2

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:到目前为止,我们讨论的是服务器端,主要涉及:

  1. How the requests from different user agents will be processed by the server.服务器如何处理来自不同用户代理的请求。
  2. How the text will be rendered with respect to different devices.文本将如何针对不同设备呈现。

Client ends could be:客户端可能是:

  1. A web browser, in this case you don't need any client app to be developed一个 web 浏览器,在这种情况下,您不需要开发任何客户端应用程序
  2. A, lets say, Silverlight app for Windows Phone A,可以说,Silverlight 应用程序用于 Windows 电话
  3. An android app for Android phone Android 手机的 android 应用程序
  4. So on so forth.以此类推。

Decide what this "client app" will do.决定这个“客户端应用程序”将做什么。 For instance, in your case:例如,在您的情况下:

  • User shall login via fb id.用户应通过 fb id 登录。
  • User shall be able to perform certain operations.用户应能够执行某些操作。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM