The IM network layer of Mushroom Street

Source: Internet
Author: User

  Mushroom Street IM network layer: API Center is responsible for the management, registration of all the API, accept server data (can be separated from the purchase, only the interface to accept data), call the parsing interface, callback API, timeout processing, have their own thread. There's a superapi. A APIPROTOCALSUPERAPI is the base class for all APIs that register request and Respone, timeout, save return closures, package data (call protocal), and send data. Apiprotocal encapsulates the parsing and packaging of protocols. The controller call implements the Protocal Superapi subclass (CHILDAPI) and passes the closure of the callback function into the SUPERAPI. The CHILDAPI implements the apiprotocal to parse the data returned by the server and returns CMD, MsgID.  apicenter has four map (Request response notify Timeout) request is requested response is reply timeout is supermarket processing notify is server notification. Every communication requires a registration request, response, and timeout. When the message finishes processing, remove from map. (notify does not need remove) the   process is as follows: 1.controller calls CHILDAPI request, incoming data (object), and completion closures. 2.CHILDAPI->SUPERAPI Request Unified Process, in center, register request and Respone, timeout, save return closure, package data (call protocal), send data. 3.superAPI calls Childapi's data package via Apiprotocol, calling Center's send. 4.center receives the bytes returned by TCP, calling Protocal (the API registered in Responsemap) to parse. 5. The parsing finishes clearing the API (request, response, timeout) in the map, callbacks the completion closure in the main thread, and passes the data past. 6.controller receive data, save to model, display processing. 7. If the timeout is reached in the 4 process, clear the request, Resonse, timeout, callback timeout closure.   

IM network layer on Mushroom street

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.