model

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2023 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID         uint64    `gorm:"column:id" json:"id"`
	NickName   string    `gorm:"column:nickname" json:"nickname"`
	Status     int       `gorm:"column:status" json:"status"`
	Broker     string    `gorm:"column:broker" json:"broker"`
	Token      string    `gorm:"column:token" json:"token"`
	CreatedAt  time.Time `gorm:"column:created_at" json:"-"`
	ModifiedAt time.Time `gorm:"column:modified_at" json:"-"`
}

func (Account) TableName

func (Account) TableName() string

type BaseRespCmd

type BaseRespCmd struct {
	Cmd  string `json:"cmd"`
	Code int32  `json:"code"`
}

type BizHub

type BizHub struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

melody.Session keys 是一个Map,多线程处理有并发问题

func NewBizHub

func NewBizHub() *BizHub

func (*BizHub) GetAllClient

func (h *BizHub) GetAllClient() []*Client

func (*BizHub) GetClient added in v0.1.0

func (h *BizHub) GetClient(accountId uint64) (*Client, bool)

func (*BizHub) RemoveClient

func (h *BizHub) RemoveClient(accountId uint64)

func (*BizHub) SetClient

func (h *BizHub) SetClient(nickName string, accountId uint64, session *melody.Session)

func (*BizHub) SetLastPong

func (h *BizHub) SetLastPong(accountId uint64, t time.Time)

type BrokerHub

type BrokerHub struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

melody.Session keys 是一个Map,多线程处理有并发问题

func NewBrokerHub

func NewBrokerHub() *BrokerHub

func (*BrokerHub) GetBroker

func (h *BrokerHub) GetBroker(brokerAddr string) (pb.BrokerClient, bool)

func (*BrokerHub) GetBrokerList

func (h *BrokerHub) GetBrokerList() []BrokerInfo

func (*BrokerHub) RemoveBroker

func (h *BrokerHub) RemoveBroker(brokerAddr string)

func (*BrokerHub) SetBroker

func (h *BrokerHub) SetBroker(brokerAddr string, client pb.BrokerClient)

func (*BrokerHub) Size

func (h *BrokerHub) Size() int

type BrokerInfo

type BrokerInfo struct {
	Addr   string
	Client pb.BrokerClient
}

type Client

type Client struct {
	Session *melody.Session `json:"-"`

	NickName  string    `json:"nickName"`
	AccountId uint64    `json:"accountId"`
	LastPong  time.Time `json:"lastPong"`
}

func NewClient

func NewClient(nickName string, accountId uint64, session *melody.Session) *Client

func (*Client) Write added in v0.1.0

func (s *Client) Write(obj any) error

type CmdCreateAccountReq

type CmdCreateAccountReq struct {
	Cmd      string `json:"cmd"`
	NickName string `json:"nickName"`
}

func NewCmdCreateAccountReq added in v0.1.0

func NewCmdCreateAccountReq() *CmdCreateAccountReq

type CmdCreateAccountResp

type CmdCreateAccountResp struct {
	BaseRespCmd
	NickName  string `json:"nickName"`
	AccountId uint64 `json:"accountId"`
	Token     string `json:"token"`
}

func NewCmdCreateAccountResp added in v0.1.0

func NewCmdCreateAccountResp() *CmdCreateAccountResp

type CmdDialogueReq

type CmdDialogueReq struct {
	Cmd       string `json:"cmd"`
	RequestId string `json:"requestId"`
	SenderId  uint64 `json:"senderId"`
	SessionId uint64 `json:"sessionId"`
	Content   string `json:"content"`
}

func NewCmdDialogueReq added in v0.1.0

func NewCmdDialogueReq() *CmdDialogueReq

type CmdDialogueResp

type CmdDialogueResp struct {
	BaseRespCmd
	RequestId string `json:"requestId"`
	MsgId     uint64 `json:"msgId"`
}

func NewCmdDialogueResp added in v0.1.0

func NewCmdDialogueResp() *CmdDialogueResp

type CmdMatchReq

type CmdMatchReq struct {
	Cmd       string `json:"cmd"`
	AccountId uint64 `json:"accountId"`
}

func NewCmdMatchReq added in v0.1.0

func NewCmdMatchReq() *CmdMatchReq

type CmdMatchResp

type CmdMatchResp struct {
	BaseRespCmd
	PartnerId   uint64 `json:"partnerId,omitempty"`
	PartnerName string `json:"partnerName,omitempty"`
	SessionId   uint64 `json:"sessionId,omitempty"`
}

func NewCmdMatchResp added in v0.1.0

func NewCmdMatchResp() *CmdMatchResp

type CmdPingReq

type CmdPingReq struct {
	Cmd       string `json:"cmd"`
	AccountId uint64 `json:"accountId"`
}

由broker发出

{
"cmd": "PING_REQ",
"accountId": 12000
}

func NewCmdPingReq added in v0.1.0

func NewCmdPingReq() *CmdPingReq

type CmdPingResp

type CmdPingResp struct {
	Cmd       string `json:"cmd"`
	AccountId uint64 `json:"accountId"`
}

由Client发出

{
	"cmd": "PING_RESP"
	"accountId": 12000
}

func NewCmdPingResp added in v0.1.0

func NewCmdPingResp() *CmdPingResp

type CmdPushDialogueReq

type CmdPushDialogueReq struct {
	Cmd       string `json:"cmd"`
	MsgId     uint64 `json:"msgId"`
	SenderId  uint64 `json:"senderId"`
	SessionId uint64 `json:"sessionId"`
	Content   string `json:"content"`
}

func NewCmdPushDialogueReq added in v0.1.0

func NewCmdPushDialogueReq() *CmdPushDialogueReq

type CmdPushDialogueResp

type CmdPushDialogueResp struct {
	BaseRespCmd
}

func NewCmdPushDialogueResp added in v0.1.0

func NewCmdPushDialogueResp() *CmdPushDialogueResp

type CmdPushSignalReq

type CmdPushSignalReq struct {
	Cmd        string      `json:"cmd"`
	SenderId   uint64      `json:"senderId"`
	SessionId  uint64      `json:"sessionId"`
	ReceiverId uint64      `json:"receiverId"`
	SignalType string      `json:"signalType"`
	Data       interface{} `json:"data"`
}

func NewCmdPushSignalReq added in v0.1.0

func NewCmdPushSignalReq() *CmdPushSignalReq

type CmdPushSignalResp

type CmdPushSignalResp struct {
	BaseRespCmd
}

func NewCmdPushSignalResp added in v0.1.0

func NewCmdPushSignalResp() *CmdPushSignalResp

type CmdPushViewedAckReq

type CmdPushViewedAckReq struct {
	Cmd       string `json:"cmd"`
	SessionId uint64 `json:"sessionId"`
	AccountId uint64 `json:"accountId"`
	MsgId     uint64 `json:"msgId"`
}

func NewCmdPushViewedAckReq added in v0.1.0

func NewCmdPushViewedAckReq() *CmdPushViewedAckReq

type CmdReConnectReq

type CmdReConnectReq struct {
	Cmd       string `json:"cmd"`
	AccountId uint64 `json:"accountId"`
	Token     string `json:"token"`
}

func NewCmdReConnectReq added in v0.1.0

func NewCmdReConnectReq() *CmdReConnectReq

type CmdReConnectResp

type CmdReConnectResp struct {
	BaseRespCmd
}

func NewCmdReConnectResp added in v0.1.0

func NewCmdReConnectResp() *CmdReConnectResp

type CmdViewedAckReq

type CmdViewedAckReq struct {
	Cmd       string `json:"cmd"`
	SessionId uint64 `json:"sessionId"`
	AccountId uint64 `json:"accountId"`
	MsgId     uint64 `json:"MsgId"`
}

func NewCmdViewedAckReq added in v0.1.0

func NewCmdViewedAckReq() *CmdViewedAckReq

type CmdViewedAckResp

type CmdViewedAckResp struct {
	BaseRespCmd
}

func NewCmdViewedAckResp added in v0.1.0

func NewCmdViewedAckResp() *CmdViewedAckResp

type CommonCmd

type CommonCmd struct {
	Cmd string `json:"cmd"`
}

type InBox

type InBox struct {
	ID         uint64 `gorm:"column:id" json:"id"`
	SenderId   uint64 `gorm:"column:sender_id" json:"sender_id"`
	MsgId      uint64 `gorm:"column:msg_id" json:"msg_id"`
	ReceiverId uint64 `gorm:"column:receiver_id" json:"receiver_id"`
}

func (InBox) TableName

func (InBox) TableName() string

type OutBox

type OutBox struct {
	ID         uint64    `gorm:"column:id" json:"id"`
	SenderId   uint64    `gorm:"column:sender_id" json:"sender_id"`
	SessionId  uint64    `gorm:"column:session_id" json:"session_id"`
	Status     int       `gorm:"column:status" json:"status"`
	MsgType    int       `gorm:"column:msg_type" json:"msg_type"`
	Content    string    `gorm:"column:content" json:"content"`
	CreatedAt  time.Time `gorm:"column:created_at" json:"-"`
	ModifiedAt time.Time `gorm:"column:modified_at" json:"-"`
}

func (OutBox) TableName

func (OutBox) TableName() string

type Session

type Session struct {
	ID         uint64    `gorm:"column:id" json:"id"`
	Status     int       `gorm:"column:status" json:"status"`
	CreatedAt  time.Time `gorm:"column:created_at" json:"-"`
	ModifiedAt time.Time `gorm:"column:modified_at" json:"-"`
}

func (Session) TableName

func (Session) TableName() string

type SessionAccount

type SessionAccount struct {
	ID        uint64 `gorm:"column:id" json:"id"`
	SessionId uint64 `gorm:"column:session_id" json:"session_id"`
	AccountId uint64 `gorm:"column:account_id" json:"account_id"`
}

func (SessionAccount) TableName

func (SessionAccount) TableName() string

type SessionWrapper added in v0.1.0

type SessionWrapper struct {
	Session *melody.Session `json:"-"`
}

func NewSessionWrapper added in v0.1.0

func NewSessionWrapper(s *melody.Session) *SessionWrapper

func (*SessionWrapper) Write added in v0.1.0

func (s *SessionWrapper) Write(obj any) error

Jump to

Keyboard shortcuts

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