Code Monkey home page Code Monkey logo

-'s Introduction

1.功能: 类似qq群功能
【1】有人进入聊天室需要输入姓名,姓名不能重复
【2】进入聊天室时,其他人会收到通知:  xxx 进入聊天室
【3】一个人发消息,其他人会收到:   xxx: xxxxxx
【4】有人退出聊天室,则其他人也会收到通知: xxx退出聊天室
【5】扩展功能: 服务器可以向所有用户发送公告
    管理员消息:xxxxxxxxx  

2. 确定技术模型
    【1】使用字典保存用户消息 {name:ip}
    【2】套接字选择: UDP套接字
    【3】转发模型: 客户端-->>服务端-->>其他客户端
    【4】收发关系处理: 多进程分别处理发送接收

3. 注意事项
    【1】设计封装方法   函数
    【2】写一个模块测试一个模块
    【3】注释的编写添加

4.具体实现流程
    【1】搭建网络连接
    【2】登入
        1. 客户端: * 输入姓名
                  * 将姓名发送给服务端
                  * 接收服务端反馈
                  * 如果不允许则重新输入,允许则进入聊天室
                  * 创建新的进程用于消息发送
        2. 服务端: * 接收姓名
                  * 判断姓名是否存在
                  * 将结果反馈给客户端
                  * 不允许登入结束,允许登入则将用户信息插入数据机构保存
                  * 创建新的进程用于消息收发    
    【3】聊天
        1. 客户端: * 循环发送消息
                  * 循环接收消息

        2. 服务端: * 接收消息,判断请求消息
                  * 将消息转发给其他用户    


    【4】退出
        1. 客户端: 
            *输入quit表示退出
            *将退出请求发送给服务器然后结束进程
            *recv接受服务器消息后退出进程

        2. 服务端: 
            *接收消息确定消息类型
            *将用户从字典移除
            *将退出消息发送给其他人
            *给改用户发送特殊标志

    【5】管理员公告

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.