model

package
v0.0.0-...-c2a03d5 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUserModel

func AddUserModel(user User)

AddUserModel will add the user model that implements the User interface

Types

type Client

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

Client represents a user connect to a room, one user may have many devices to chat, so it should not be the same as user

func NewClient

func NewClient(socket *websocket.Conn, h *Hub, room string) *Client

NewClient created

func (*Client) Read

func (c *Client) Read()

Read from client socket

func (*Client) Write

func (c *Client) Write()

Write in client socket

type Hub

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

Hub represents a websocket hub having multiple clients per room

func NewHub

func NewHub() *Hub

NewHub creates a new websocket hub where clients will join in respective channel

func (*Hub) Join

func (h *Hub) Join(client *Client)

Join will forward the client to a join

func (*Hub) Leave

func (h *Hub) Leave(client *Client)

Leave will forward the client to remove

type Message

type Message struct {
	ID       string                 `json:"id" bson:"_id"`
	Msg      string                 `json:"msg" bson:"msg"`
	Room     string                 `json:"room" bson:"room"`
	LoginID  string                 `json:"login_id" bson:"login_id"`
	Type     string                 `json:"type" bson:"type"`
	Metadata map[string]interface{} `json:"metadata,omitempty" bson:"metadata"`
	CreateAt time.Time              `json:"created_at,omitempty" bson:"created_at"`
}

Message represents the message send by client sent

type User

type User interface {
	GetUserLoginID() string
}

User is user interface which need to be implemented

Jump to

Keyboard shortcuts

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