aermin / ghChat

:octocat: 📱A chat application for GitHub. React + PWA + Node(koa2) + Typescripts + Mysql + Socket.io

Home Page:https://im.aermin.top/group_chat/ddbffd80-3663-11e9-a580-d119b23ef62e

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

koa2- remove

ciaoamigo opened this issue · comments

Hi, I'm asking for your code.
I saw that you use koa2 is a great framework, but it is only used in the authentication/login phase.
To improve the performance and make the code more homogeneous, I would use only socket.io
So it's better to remove koa2 and use socket.io also for registration and login.
What do you think about it?

Hi, I'm asking for your code.
I saw that you use koa2 is a great framework, but it is only used in the authentication/login phase.
To improve the performance and make the code more homogeneous, I would use only socket.io
So it's better to remove koa2 and use socket.io also for registration and login.
What do you think about it?

Hi, @ciaoamigo . I think using socket.io in authentication/login/register worries me about the performance because socket.io will take long connection. And in these scenarios, the long connection is not necessary but increasing the server pressure. So I decided to use HTTP instead of socket.io in these scenarios and start the long connection by socket.io after the user logs in. It is just my personal opinion, welcome to discuss. 😃

Sure. But just connect via socket only when:

  1. When I log in
  2. When I register.
    This makes the application homogeneous with the following advantages:
  • all connections to the backend come only via socket;
  • easier to create a sdk-client to use with both react.js and react-native
  • simpler maintenance as less technology is used;
    etc.

Sure. But just connect via socket only when:

  1. When I log in
  2. When I register.
    This makes the application homogeneous with the following advantages:
  • all connections to the backend come only via socket;
  • easier to create a sdk-client to use with both react.js and react-native
  • simpler maintenance as less technology is used;
    etc.

Good idea.👍
I got it. Init to connect socket and emit request when the user clicks the button to log in or register. I will refactor it in the future. Thank you very much.

If you are interested in it, welcome to develop this project together. 😄

Hi, @ciaoamigo. I am going to refactor the part where we talk about. But I find that If I use socket.io instead of the HTTP request When the user clicks the register button but fails, at this time the server has to keep connect to client(long connect, needless performance loss) because the user maybe tries against after a period of time. What do you think about?