当前位置:网站首页>PHP laravel+gatewayworker completes im instant messaging and file transfer functions (Chapter 2: explanation of business logic)

PHP laravel+gatewayworker completes im instant messaging and file transfer functions (Chapter 2: explanation of business logic)

2022-06-26 12:18:00 Special sword

Function introduction

This topic will lead you to build Imitation A letter Of Instant messaging And complete the mutual transmission of documents

Application scenarios

Practical application scenarios of this topic :

  1. Chat customer service : Instant messaging , Messages are transmitted to each other in real time , Send text to each other 、 Voice messages and files ;
  2. Small scale online auction ;
  3. Video live barrage ;
  4. The Internet of things ;
  5. And other functions related to real-time messages ;

Special sections

  1. Server configuration
  2. Explanation of business logic
  3. Back end instant messaging code development and configuration item explanation
  4. Server debugging error
  5. Front and back end code development
  6. Function display

Chapter two : Explanation of business logic

One 、 Business logic

The specific implementation principle manual is more detailed than what I said GatewayWorker working principle ;
Now let me briefly say , In the past without electronic communication equipment , It takes a few steps to have a word with you in the distance ?

  1. I write what I want to say on the letter paper with a pen ;→ Type in the text input
  2. I sent this letter to the post office and told the address to receive it ;→ Click on button The button is submitted to the controller written by us at the back end
  3. The post office will deliver the letter to you according to the address ;→ Our controller according to the letter “ Receiving address ” call Gateway::sendToClient($ Receiving address , $ The content of the letter ); Send you a letter
  4. You open the letter and read ;→ user B Of web Front end chat page js adopt ws.onmessage() Method to receive the message and render it on the front-end template
  5. End of one-way communication ;→ Continuous connection ;

Then you want to reply to my letter in several steps ?

  1. You write what you want to say on the letter paper ;→ Write what you want to say in input in
  2. You take your letter to the post office, tell the receiving address and ask the mail to deliver it for you ;→ Click on button Submit button , Send content to our controller , Our controller is calling Gateway::sendToClient($ Receiving address , $ The content of the letter ); To deliver a letter
  3. Find me by mail according to the receiving address and give me your letter ;→ user A Of web Front end chat page js adopt ws.onmessage() Method to receive incoming messages
  4. I opened it to read → user A Of web Front end chat page js adopt ws.onmessage() Method to receive the message and render it on the front-end template

This process is designed to cover those roles ?

  1. I ( user A): The first person to send you a letter
  2. you ( user B): The person who received my first letter
  3. Post Office : Someone who helps us deliver the letter
  4. Postman : Who helped us deliver the letter

Then map this process to what is in the program ?

  1. user : This is easy to understand , Is the person who uses this communication program ;
  2. Post Office : amount to MVC Inside the frame Controller Business controller ;
  3. Postman : Who helped us deliver the letter GatewayWorker

Last chapter :《1. Server configuration

Next chapter :《3. Back end instant messaging code development and configuration item explanation

原网站

版权声明
本文为[Special sword]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202170522215328.html