Apple APNs HTTP2 protocol provider API, is a relatively new interface, a simple study, think this direction need to engage in a library to achieve this:
1. Now the back-end service trend, peers after the piecemeal, simply said that there is a similar to Google or APNs platform-level interface (HTTP/2 + TLS can also be directly called H2, should be the trend of the future)
2. Most developers also need a more downstream interface to handle the complexity here,
3. A common implementation of a large number of Client connection library, has a relatively large practical significance.
In general, a good library, essentially a universal framework, abstract solves a class of problems, concrete implementation is similar to a demo.
SSL, for example, is actually a demo on EVP bio.
Now it's unclear what the idea is.
/*------------The idea of modularity, it is best to remove the input and output after the logical part can be compiled independently best to become an API library, implement APNS protocol, take into account the performance of the input part of MQ or other interface is the message output cycle point, hook Hook, Hair msgsycle, the result of the feedback, the certificate fails the make standalone when the output of the default hook to hit log, the input can be called by itself command line Apns2--devicetoken/--uid-- Appkey/--pem--msg best stateless, not the two-level queue, not the full lock kill-term graceful termination of the deployment on the non-differentiated 012 queue, Fight for the stepless variable speed queue Part API session, may allow the replacement of multi-threaded see the situation idle task Idle-task State Monitoring, It's best to write state files Pid.status GC Check for a long time useless appkey, turn the connection off-------------------------deployment structure apns2-d--daemonctl-apns2pid/22222. timeconf/log/script/certfile/-----------Processing Point token success failure timeout take badge success failure timeout certs success failure Timeout Dnsconnectssl_connectloop Send ( Req) res = recv ()-------------libjemalloc NGHTTP2-------------Date Structure*/namespaceapns2 {}typename msgid_t;typename appkey_t;typename payload_t;typename time_t;typename uuid_t;typename uid_t; TypeName Token_t;typename badge_t;structmessage{msgid_t MsgId; appkey_t Appkey; payload_t payload; Time_t received; time_t expiration; //prior_t priority; not Impl default=10};structnode{uuid_t ID; uid_t uid; Token_t token; badge_t Badge_value; msgid_t MsgId; time_t ready; Time_t sent; time_t responsed; state_t current;};structpayload_t{msgid_t MsgId; time_t Create;//? Creation time byte[] data;};structstream_t{intstream_id;};structconnection_t{appkey_t Appkey; Hash<stream_id,stream_t>streamsintSOCKFD; SSL SSL; time_t timeout};send (STREAM_T,BUF); recv (STREAM_T,BUF);structcertificate{appkey_t Appkey; certfile_t CertFile;};structtimer_t{TIMERFD FD; Lambda F;};------------multiplexer {Set<connection_t>()}classqueue{ Public: Enqueue (node n); Dequeue (Constuuid_t&ID); Node Peek1 (); Node Peek1 (Constuuid_t&ID); Associate (Payload_pool p);};classpayload_pool{ Public: Add (payload_t p); Del (msgid_t msgid);};/*----------Connect-----State Machine of node------flow-------: Host Api.development.push.apple.com:2197:method post:path/3/device/<device-token>-----apns-http2/apns-http2.h apijpush-apns2.h framwork,commlib,j Pushjpush-apns2.cpp set Config,set hooks Etc,jpush onlymain.cpp mainthird/http-parser/nghttp2/ uv.h/t/------------issue, SSL connection string push (string token, string certificate, string payload); function at present if a msgid is taken, it cannot be sent back. Actually should send back to retry first consider the mechanism, the data structure is correct, the strategy is simple*/
Start preparing for a provider to achieve HTTP/2.