I
I
Ivan Vorobei2016-08-06 09:05:51
API
Ivan Vorobei, 2016-08-06 09:05:51

WEBsokect and Rest API - replace each other?

Implemented REST API server on Laravel. Everything is according to Feng Shui, protocol best practices, error codes, etc.
But there was a need to tie the messenger to the server. If it’s still somehow clear with the database, then I don’t understand how web sockets get along with REST. And should they get along?
Or is it correct to rewrite zero, and when you open it, immediately start the session?
Sobsna question: do I need to combine rest and sockets, or switch exclusively to sockets?
It would be nice in the context of Laravel

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2016-08-06
@ivanvorobei

Sobsna question: do I need to combine rest and sockets, or switch exclusively to sockets?
Sobsna, as you want, do it: REST-police and Socket-Nazi do not exist. Fundamentally, the REST API is no different from the API on sockets (of course, I do not include push data from the server in this definition). When you need some data on the client, you must request it. And whether you will receive them via ajax or via sockets is completely unimportant. I have projects where the combinations are very different: from pure REST to pure sockets and everything in between.
But in the context of Laravel, you won’t write a socket server, so if you don’t want to change the technology stack, then use it as expected by the framework : REST API to receive data, permanent connection to some pusher on the client and send changes there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question