📜 ⬆️ ⬇️

Interactive site with post-hawk? Easy!

Hello% habrauser%!

Time is running forward and we must keep pace with it. Static sites are left somewhere far behind, perhaps over time, ajax will become obsolete, the era of web sockets will come in all browsers and everyone will be happy, utopia, of course ... Today I want to introduce you a service that will allow you to implement Your site is an element of complete interactivity. Would you like to send information to clients not when the user asks or the timer runs in js, but when the server needs it, while limiting itself to the minimum amount of code and without using ajax? Then the Post Hawk service is for you!

Small description


The main task of the service is to transfer your messages between users of the site, that is, you tell someone to send a message, the service does it. On the client side, communication is carried out at the expense of web sockets, at the server side - at the expense of curl or sockets. You can initiate the process of sending a message from the backend upon the occurrence of some event, for example, someone added a comment to the post and it is necessary that it appears to all connected clients, all you need to do is call an api . One of the most difficult tasks was to make it simple and straightforward, not requiring half a day to understand and another week to screw on. While it is available only for php and js, however, its implementation for other languages ​​does not require much time. The code is open and is here .
')

How is the process going?


It's simple. You register with the service, add the domain (s) from which messages will be sent, connect one class on the server side, one tiny library on the client side and subscribe to events. Libraries are here . Well, then do with the messages that came, whatever you want.

An example of the simplest class of chat using the service is attached to the library and fits into just 150 lines of code. Based on this class, a chat is implemented on the service website. In this article I will not give the code of interaction with api, this information is presented in the corresponding section of the site.

What is under the hood?


The service itself is written in, ideally suited for such a task, Erlang / OTP is used as data storage by mongodb. Replacing the code without stopping the server, out-of-the-box scalability, simple work with binary data and many more “tasty” who are interested in looking for articles about Erlang on Habré.

What are the advantages?


The most important thing is that nothing needs to be put on the server, unlike, for example, RabbitMQ, i.e. will work even on weak hosting. No need to write bikes to support communication with the server. Everything is elementary simple.

What are the disadvantages?


The technology of web sockets is supported only by modern browsers, in thoughts there is a desire to make support for old ones, but there is no time for that. The wss protocol is not supported yet, but it is in the plans. Since the service does not save and does not handle messages passing through it, this concern falls on the shoulders of the developer. Some api methods are missing, for example, messages from the server can only be sent to groups of users, but not just to everyone.

A little privacy.


The service does not save your messages. If you are afraid for the security of the transmitted data, you can use any encryption library, both on the client ( several libraries ) and on the server (for example, mcrypt) in any case the service does not need your messages. Only the fact of transmission for collection of statistics is recorded. It is planned to finalize the client library to support out-of-box encryption.

How much is?


Bye for free. The service is in the beta stage and no restrictions are planned.

Our mission


The service does not set the task to enrich its creators. At some point, I realized why I was doing this, and another goal appeared - to help children who need it by transferring money to the appropriate funds and targeted assistance. Where it came from is difficult to say, but from the moment I set it in front of me, the process went much easier. While there is no jur. Persons, and it is not known whether it will be necessary, on the site there is a script for donating through Yandex.Money and web money wallet numbers. A little later I will make a page with reports on the funds transferred (if there is anything to report on).

Thank you for attention!
I hope it turned out something useful. I will be glad to any constructive criticism and suggestions.

Source: https://habr.com/ru/post/241774/


All Articles