A
A
Alexander2014-04-13 21:06:09
Mobile Internet
Alexander, 2014-04-13 21:06:09

Transport API messages via socket.io in mobile applications: good or bad?

Actually, I am tormented by the question of how best to implement the API:
1) Do everything (api + sending data / events / etc from the server to the client) using socket.io
2) Make the api separately, the usual REST / JSONRPC + optionally, run socket on desktops .io, for loading data in real time
On the one hand, socket.io allows you to push data from the server to the client in real time and has a bunch of fallbacks. On the other hand - if I'm taking the subway / using slow GPRS - wouldn't socket.io be a big overhead?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
S
Sergey, 2014-04-13
@tru3

In this case, the choice is correct. You can of course use HTTP. But in this case, it is a big overhead, because. the connection is reset each time.
The fact that someone's connection is broken somewhere in the metro is the problem of this chela, and the connection will be broken - it will immediately be restored when necessary.

E
Enniack, 2015-09-16
@Enniack

Everything is very simple, the action was really wrong.
Didn't request a directory - <?php echo get_template_directory_uri(); ?>/mail.php

W
WebSpider, 2015-09-14
@WebSpider

header("refresh:3;url=http://sitename.ru");
Instead, you need to write
it out

H
heartdevil, 2015-09-14
@heartdevil

Hello.
If it's wordpress, then you'd be better off using the standard way of processing forms.
The form action should be on admin-post.php. Plus, you need to add a hidden field and nounce for form security.
Read about nounce https://codex.wordpress.org/WordPress_Nonces
This is how an example form creation looks like

<form name="loginForm" id="loginForm" action="<?php echo esc_url(get_admin_url() . 'admin-post.php') ?>" method="post">
  <input type="hidden" name="action" value="login-form" />
  <?php wp_nonce_field('process_login_form_action','login_form_sec_field'); ?>

Next, in the functions.php file,
you write the handler for this form.
add_action('admin_post_submit-form', 'process_mail_form_action'); // для залогинненых пользователей
add_action('admin_post_nopriv_submit-form', 'process_mail_form_action'); // для незалогинненых пользователей один и тот же обработчик
function process_mail_form_action()
{
// тут читаете из $_POST
}

Don't forget to handle the nouce field in code.

D
Dmitry Entelis, 2015-09-14
@DmitriyEntelis

If he throws at 404, then he throws somewhere in the wrong place. What is the url of the form page?
In telepath mode: try
action="/mail.php"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question