A small project for a simple chatroom using golang.

chatroom_go

A small project for a simple chatroom using golang.

项目编码流程的设计分析

通讯逻辑示意图

image

客户端部分

客户端登录功能

1.接收的输入id和密码

2.接收服务端的返回结果

3.判断是成功还是失败,并显示对应的页面

客户端发送消息流程

1.创建一个Message的结构体,结构体存放消息的类型和消息本身的数据(要有用户名和密码)

2.mes.Type = 登录的消息类型

3.mes.Data = 登录消息的内容

4.对mes和mes.Data进行序列化

5.在网络传输中,最麻烦的就是丢包问题

(1)先给服务器发送mes的长度【有多少字节】

(2)再发送消息本身

6.等待服务端发送是否合法的指令loginResMes。

服务端部分

服务端验证登录部分

1.接收用户的id密码,这里要开启协程,处理多个请求

2.验证用户的用户名和密码

3.返回结果

服务端接收数据的流程

1.接收客户端发送的长度以及Message的结构体的

2.接收时候要判断实际接收到的消息内容是否等于这个长度len,如果不等于就是丢包了,不相等就设置纠错协议

3.取到后对mes进行反序列化,得到原本的mes

4.再取出message.Data进行反序列化

5.取出loginMes.userId和login.userPwd

6.验证登录是否合法,返回给客户端序列化后的loginResMes(该变量用来表示是否合法)

Owner
Ripple
@OSSDAO-ORG•AIRDROP-0xA1a5F57f6042eFCB85087779707d654D6f14B1ba
Ripple
Similar Resources

Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like. This repository holds my submission/answers for these challenges.

Advent of Code - Zach Howell's Answers Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels

Jan 4, 2022

Catfetch is a small and cute fetch program written in Go

 Catfetch is a small and cute fetch program written in Go

🐱Catfetch is a small and cute fetch program written in Go

Oct 30, 2022

Spellingbee - A small Go program to generate solutions to the NYT Spelling Bee

Spellingbee solver A small Go program for generating solutions to the ]New York

Jan 31, 2022

Golang-module-references - A reference for how to setup a Golang project with modules - Task Management + Math Examples

Golang Module Project The purpose of this project is to act as a reference for setting up future Golang projects using modules. This project has a mat

Jan 2, 2022

This is a simple project for demonstrating Temporal with the Go SDK.

This is a simple project for demonstrating Temporal with the Go SDK.

This is a simple project for demonstrating Temporal with the Go SDK.

Oct 11, 2021

The phylosophy behind readyGo is "A Simple configuration should give a working project.".

The phylosophy behind readyGo is

The phylosophy behind readyGo is "A Simple configuration should give a working project.". readyGo is a command line interface( probably the name of re

Oct 30, 2021

Ultra simple project scaffolding

Ultra simple project scaffolding

💛 You can help the author become a full-time open-source maintainer by sponsoring him on GitHub. aho ultra simple project scaffolding Install curl -f

Dec 28, 2022

A simple project/module generated tool written in go

A module generator written in go This is a project/module generator written in go. It is intended to generate standard project/module layouts in the t

Oct 17, 2022

simple bank which is implemented using Golang

Banker The service that we’re going to build is a simple bank. It will provide APIs for the frontend to do following things: Create and manage bank ac

Nov 15, 2021
Moby Project - a collaborative project for the container ecosystem to assemble container-based systems
Moby Project - a collaborative project for the container ecosystem to assemble container-based systems

The Moby Project Moby is an open-source project created by Docker to enable and accelerate software containerization. It provides a "Lego set" of tool

Jan 2, 2023
Placeholder for the future project (lets-go-chat)Placeholder for the future project (lets-go-chat)

Placeholder for the future project (lets-go-chat)Placeholder for the future project (lets-go-chat)

Jan 10, 2022
A boilerplate/starter project for quickly building APIs using Golang with Clean Architechture
A boilerplate/starter project for quickly building APIs using Golang with Clean Architechture

A boilerplate/starter project for quickly building APIs using Golang with Clean Architechture

Mar 2, 2022
A simple and sussy project is an implementation of SOMMIP Lab 1 written in Golang
A simple and sussy project is an implementation of SOMMIP Lab 1 written in Golang

SOMMIP Lab 1 Isac Arthur Table of Contents About The Project Getting Started Prerequisites Installation Supported commands About The Project This very

Nov 10, 2021
PKSUID is a small extension for KSUID (K-Sortable Globally Unique IDs) which allows prefixing it with arbitrary up to 16 bytes strings

PKSUID is a small extension for KSUID (K-Sortable Globally Unique IDs) which allows prefixing it with arbitrary up to 16 bytes strings

Dec 1, 2022
A small web dashboard with stats for all pipelines of Buildkite organization.
A small web dashboard with stats for all pipelines of Buildkite organization.

Buildkite Stats A small Buildkite dashboard useful to prioritize which pipelines a Buildkite organization is waiting the most on. Noteworthy details:

Apr 25, 2022
A small API to be used in Traefik Forward Auth to block attacks on services behind your favorite web router

Dynamic IPs Blacklist for Traefik This small software implements the possibility to block access to all the services behind your Traefik service. The

Sep 2, 2022
Graphical small-internet client for windows, linux, MacOS X and BSDs. Supports gemini, http, https, gopher, finger.
Graphical small-internet client for windows, linux, MacOS X and BSDs. Supports gemini, http, https, gopher, finger.

Graphical small-internet client for windows, linux, MacOS X and BSDs. Supports gemini, http, https, gopher, finger.

Jan 1, 2023
Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Advent of Code 2021 Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved

Dec 2, 2021
A little tool to create small QR code cards for vaccination/test proof.

Icedream's fancy vaccination/test certificate card tool This is just a tool I wrote to transform my vaccine certificate QR codes into something I can

Dec 16, 2021