GithubHelp home page GithubHelp logo

junzi528 / wschat Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 2.0 92 KB

用swoole的websocket+php原生+redis+vue,实现的简单的一对一网页聊天,总共就写了6个文件,其中3个文件都只有几行代码。动态创建用户,且会保存聊天记录。

PHP 97.18% HTML 2.82%

wschat's Introduction

用swoole实现的最简单的一对一网页聊天

简介

  • 用于学习swoole,实现了一对一聊天的基本功能。
  • 打开一个网页,即创建一个在线用户,不用注册。关闭网页后,用户就消失。
  • 后端使用原生php和redis扩展,前端使用了vue
  • redis主要用于管理在线用户和保存聊天记录

使用方法

  1. 在安装了swoole和redis扩展的php环境下,在命令行中执行 php swoole.php,开启服务
  2. 在浏览器中打开user.html文件,可以多开几个窗口,模拟多人聊天。
  3. 输入昵称后,选择任何一个人,即可开始一对一聊天。(至少同时有两个人在线才能进行)
  4. 若有其它人给你发来新消息,它的名字后面会有红点提示。
  5. 类似QQ,点击在线用户列表中的任何一个人,即会拉取和它的聊天记录,并且可马上聊天。

文件说明

  1. swoole.php 用swoole创建的websocket服务
  2. Base.php 基础文件,主要是对redis的操作
  3. saveNewUser.php 有新用户连接后,需要调用的接口
  4. getUserList.php 获取用户列表接口
  5. getChat.php 获取聊天记录接口
  6. user.html 前端页面,使用了vue

wschat's People

Contributors

junzi528 avatar

Stargazers

Sinmu avatar  avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

i-klaus passionor

wschat's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.