chatservice

package
v0.0.0-...-a4040c8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CollectionMessages *mongo.Collection

CollectionMessages is for message db

View Source
var CollectionRoom *mongo.Collection

CollectionRoom is for room db

View Source
var CollectionUser *mongo.Collection

CollectionUser is for user db

Functions

This section is empty.

Types

type Connection

type Connection struct {
	// contains filtered or unexported fields
}

Connection is for Server have several connection ?

type Message

type Message struct {
	SenderAlias string `bson:"sender_alias"`
	Message     string `bson:"message"`
	Time        string `bson:"timestamp"`
}

Message is content message sent by user

type Room

type Room struct {
	RoomID   string    `bson:"room_id"`
	Messages []Message `bson:"messages"`
}

Room is room created by User

type Server

type Server struct {
	Connnection []*Connection
}

Server is the interface service of this service

func (*Server) CreateStream

CreateStream is for stream the message to client

func (*Server) RegisterOrJoinRoom

func (s *Server) RegisterOrJoinRoom(ctx context.Context, req *chatservice.RoomRequest) (*chatservice.RoomResponse, error)

RegisterOrJoinRoom is to register or join a room, user will move to other room if the requested user don't have room

func (*Server) RegisterOrLoginUser

func (s *Server) RegisterOrLoginUser(ctx context.Context, req *chatservice.LoginRequest) (*chatservice.LoginResponse, error)

RegisterOrLoginUser is for login or register

func (*Server) SendMessage

func (s *Server) SendMessage(ctx context.Context, req *chatservice.ContentMessage) (*chatservice.Empty, error)

SendMessage is for broadcast all message to client

type User

type User struct {
	UserAlias string `bson:"user_alias"`
	RoomID    string `bson:"room_id"`
}

User is sender or receiver

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL