SL IM chat room based on soft + layim

brief introduction

sl-im Is based on Swoft Microservice collaboration framework and Layim Chat room developed by web chat system.

Experience address

sl-im https://im.gaobinzhan.com

Demonstration map

 

 

 

function

  • Sign in (Http)
  • Single sign on (Websocket)
  • Private chat (Websocket)
  • Group chat (Websocket)
  • Number of people online (Websocket)
  • Get unread message (Websocket)
  • Friends online status (Websocket)
  • Friend lookup add consent deny (Http+Websocket)
  • Group creation lookup add consent deny (Http+Websocket)
  • Chat record storage
  • Heartbeat detection
  • message replay
  • Broken line reconnection

Requirement

Deployment mode

 

Composer

composer update

  

bean

app/bean.php

'db' => [
        'class'    => Database::class,
        'dsn'      => 'mysql:dbname=im;host=127.0.0.1:3306',
        'username' => 'root',
        'password' => 'gaobinzhan',
        'charset'  => 'utf8mb4',
    ],
'db.pool' => [
        'class'     => \Swoft\Db\Pool::class,
        'database'  => bean('db'),
        'minActive' => 5, // Adjust the connection pool size by yourself
        'maxActive' => 10
    ],

  

Data table migration

php bin/swoft mig:up

  

 

env configuration

vim .env

# basic
APP_DEBUG=0
SWOFT_DEBUG=0

# more ...
APP_HOST=https://im.gaobinzhan.com/
WS_URL=ws://im.gaobinzhan.com/im
# Whether to turn on static processing? Here I turn off nginx to process
ENABLE_STATIC_HANDLER=false 
# Swoole under v4.4.0, where absolute path is required
DOCUMENT_ROOT=/data/wwwroot/IM/public

  

nginx configuration

server{
    listen 80;
    server_name im.gaobinzhan.com;
    return 301 https://$server_name$request_uri;
}

server{
    listen 443 ssl;
    root /data/wwwroot/IM/public/;
    add_header Strict-Transport-Security "max-age=31536000";
    server_name im.gaobinzhan.com;
    access_log /data/wwwlog/im-gaobinzhan-com.access.log;
    error_log /data/wwwlog/im-gaobinzhan-com.error.log;
    client_max_body_size 100m;
    ssl_certificate /etc/nginx/ssl/full_chain.pem;
    ssl_certificate_key /etc/nginx/ssl/private.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    location / {
        proxy_pass http://127.0.0.1:9091;
        proxy_set_header Host $host:$server_port;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Real-PORT $remote_port;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
    location /im {
        proxy_pass http://127.0.0.1:9091;
        proxy_http_version 1.1;
        proxy_read_timeout   3600s;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
    location ~ .*\.(js|ico|css|ttf|woff|woff2|png|jpg|jpeg|svg|gif|htm)$ {
        root /data/wwwroot/IM/public;
    }
}

  

Start

  • Hang up
php bin/swoft ws:start

  

  • Daemonization
php bin/swoft ws:start -d

  

  • Visit

How to access and write??? Like it

Thank you to the swoft team

PHP Senior Development Engineer resume creation, wish you gold three silver four job hopping and salary increase

Tags: PHP Nginx SSL Database

Posted on Fri, 17 Apr 2020 07:55:57 -0700 by Wesf90