Bean mail windows client (third-party) development details, client details

Source: Internet
Author: User

Bean mail windows client (third-party) development details, client details

 

"Bean mail" is a function module similar to private messages on the Community website "Douban. On the official Douban.com website, "Douban.com" was once changed to "private mail", but it was changed back after strong opposition from many douban.com users. However, on the mobile client of Douban, it is still called "private message ".

I think Bean mail was initially used as a form of mail for communication between users. With the popularity of mobile terminals, bean mail was used by many users as instant messaging software, it cannot be stopped.

"Isn't it possible to add qq or something ?"

"No, that is not literature ."

In order to carry forward this bad ethos, I decided to write a desktop software so that many young man of Douban literature and art can chat while working, and no longer need to read mobile phones frequently.

-------------- The following is the body -------------

I. Douban API    1. Use Fiddler Analyze the requests sent by the android client.

  Brief steps: Enable "allow remote connection" for Fiddler and set the port number. The mobile phone and computer must be in the same wifi network and set the proxy for the mobile phone wifi to the computer. At this time, all http requests of mobile phones can be monitored in Fiddler. Then enable https listening, set host filtering, and only listen to the api address of Douban.

On the Composer tab, you can clearly display the request Url, header, body, and other information. You can modify the data at will for debugging.

Then we get various APIs of Douban, including logon and logout, getting user information, chat list, chat content, follow list, and Message notification.

2. OAuth2.0 authentication and authorization

After you log on with the user name and password, an access token and refresh token are generated. The access token is used as the unique credential for user login. You can assign it to the Authorization: Bearer in the header request during use. After logging on for the first time, we save the access token to the local device so that the user can log on directly next time without entering the user name and password again.

OAuth2.0 designs the access token as short-lived and will expire within a certain period of time. We can use refresh token to refresh the access token as needed to form a new credential. The specific method is to change the value of grant_type in the request to refresh_token.

Ii. Use WPF to draw the interface 1. Use XAML to simulate the windows client interface.

The interface effect is as follows:

2. Use the web Front-end to build a simple chat window.

The chat window uses the WebBrowser control that comes with WPF. The default kernel version is IE7 (you can change the Registry to a later version of IE). Naturally, H5 and CSS3 are not supported. If you hate IE, you can use a third-party browser kernel control. Then, write the CSS style and JS interaction by yourself, and simply test the compatibility problem.

3. High-resolution screen adaptation

WPF native supports high resolution and happiness.

The only difference is that the WebBrowser control is not scaled by default on a high DPI screen. Fortunately, IE supports the zoom attribute. We can set the zoom attribute of the webpage body through a certain scaling ratio. How can we determine this proportion? Generally, 96 DPI corresponds to 100%, and 144DPI corresponds to 150%. OK. Solve the problem.

Iv. Background logic 1. multi-thread separation ensures smooth interface

Make sure to put the http request service in the background for execution, and you cannot wait for the interface at any time. In this example, tasks are used for processing.

2. "instant" chat experience

The Douban API has an interface for separately monitoring message reminders. You can return the number of unread messages and the reminder version number. We only need to round the request and compare the returned version number, you can remind or display unread messages.

3. The MVVM data binding mode greatly improves the programming experience.

I have always said yes.

5. functions to be supplemented

1. Send and display emoji expressions.

2. Search for new users.

Vi. References and thanks 1. Inspired by the following articles:

[Completely open-source] zhihu daily UWP (Part 1): interface design and official API analysis

UWP development control: Use WebView as a chat box

2. Use the following open-source components:

Json. NET

VII. Open source release

After the software is fully functional, the installation package and source code will be open for mutual learning and communication.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.