Versions in this module Expand all Collapse all v1 v1.2.0 Mar 3, 2025 Changes in this version + func Pub(topic string, data any) + func Sub(topicId string, user *User) + func SubFunc(topicId string, f func(msg *TopicMsg)) type Client + ClientId string + HttpRequest *http.Request + HttpWriter http.ResponseWriter + IpAddressPort string + func (c *Client) GetIP() string type Context + func (c *Context) AddLog(log string) + func (c *Context) FlushLog() type Value + func (v *Value) By(t any) + func (v *Value) IsNil() bool v1.1.0 Nov 13, 2024 v1.0.1 Aug 9, 2024 v1.0.0 Jun 18, 2024 Changes in this version + var ErrAuthentic = NewError(sys, 1141, "Please login first") + var ErrCertificationExpired = NewError(sys, 1121, "Login has expired") + var ErrJwtBLOCKED = NewError(sys, 1123, "Login has expired") + var ErrParamsInvalid = NewError(sys, 1131, "Invalid parameters") + var ErrServerError = NewError(sys, 1100, "Server under maintenance") + var ErrUncertified = NewError(sys, 1120, "Please log in first") + func BindingErrors(e error) error + func Code(action string, code int, msg string) []byte + func Data(action string, data any) []byte + func Dispatcher(c *Client, request string) + func HttpHandler(w http.ResponseWriter, r *http.Request) + func IsValidStatus(s UserOnlineStatus) bool + func Msg(action, msg string) []byte + type Action struct + Action string + Code int + Data any + Msg string + func New(action string) *Action + func (m *Action) Encode() []byte + func (m *Action) WithCode(code int) *Action + func (m *Action) WithData(data any) *Action + func (m *Action) WithMsg(msg string) *Action + type ActionManager struct + func InitManager() *ActionManager + func (m *ActionManager) Add(name string, router HandlersChain) + func (m *ActionManager) Handlers(name string) HandlersChain + func (m *ActionManager) Has(name string) bool + type ApiData struct + Code int + Data any + HttpStatus int + Msg string + type Appid int + type Client struct + AppId string + AuthCode string + Closed bool + Conn net.Conn + ConnectionTime time.Time + Disconnecting bool + Endpoint string + ErrorCount int + ForceDialogId string + GroupId string + Hub *Hubc + IpAddress string + IpConnAddr string + IpLocation string + IsLogin bool + Keys map[string]any + LastHeartbeatTime time.Time + LastMsgId int + LastRequestTime time.Time + LoginAction string + MerchantId uint + OnceId string + Platform string + RequiredValid bool + Scope string + Send chan []byte + StoreId uint + SyncMsg bool + TenantId uint + User *User + ValidCacheData any + ValidExpiry time.Time + Validated bool + func (c *Client) Close() + func (c *Client) GetKey(key string) *Value + func (c *Client) Log(symbol string, msg ...string) + func (c *Client) Reader() + func (c *Client) SendMsg(msg []byte) + func (c *Client) SendRawMsg(code int, action, msg string, data any) + func (c *Client) SetKey(key string, value any) + func (c *Client) Write() + type Context struct + Action string + Client *Client + Params string + Response *Action + Server *Server + func (c *Context) Abort() + func (c *Context) BindingJson(s any) error + func (c *Context) BindingJsonPath(s any, path string) error + func (c *Context) BindingValidateJson(s any) error + func (c *Context) Broadcast(msg *Action) + func (c *Context) Get(key string) string + func (c *Context) GetBool(key string) bool + func (c *Context) GetId(key string) uint + func (c *Context) GetInt(key string) int + func (c *Context) GetJson(s any) error + func (c *Context) GetMinInt(key string, min int) int + func (c *Context) GetPagination() *Pagination + func (c *Context) GetRangeInt(key string, min, max int) int + func (c *Context) GetSizePagination(pageSize int) *Pagination + func (c *Context) GetSliceVal(key string, options ...string) string + func (c *Context) Next() + func (c *Context) Send(data any) + func (c *Context) SendActionData(action string, data any) + func (c *Context) SendActionMsg(action, msg string) + func (c *Context) SendCode(code int, msg string) + func (c *Context) SendMsg(msg string) + func (c *Context) SendOk() + func (c *Context) SendRawTo(uid string, msg *Action) + func (c *Context) SendTo(uid, action string, data any) + func (c *Context) SendToApp(appId string, msg *Action) + func (c *Context) SendToApps(msg *Action) + type Error ApiData + func NewError(appId Appid, code int, msg string) *Error + func (e *Error) WithError(err error) *Error + func (e *Error) WithHttpStatus(status int) *Error + func (e *Error) WithMsg(msg string) *Error + type H map[string]any + func (h *H) Get(key string) (any, bool) + func (h *H) Marshal() []byte + func (h *H) Set(key string, val any) + func (h *H) Unmarshal(v any) error + type HandlerFunc func(a *Context) + type HandlersChain []HandlerFunc + type Hubc struct + Connection chan *Client + Disconnect chan *Client + GuestCount int + Guests []*Client + LoginCount int + PubSub *PubSub + Users *sync.Map + var Hub *Hubc + func NewHubc() *Hubc + func (h *Hubc) Broadcast(msg []byte) + func (h *Hubc) Run() + func (h *Hubc) User(uid string) *User + func (h *Hubc) UserClient(uid, appId string) *Client + func (h *Hubc) UserLogin(uid, appId string, client *Client) error + type IRouter interface + Add func(name string, fn ...HandlerFunc) + Group func(name string) IRouter + Use func(middleware ...HandlerFunc) IRouter + type Location struct + AdInfo []string + Address string + CityCode string + LatestUpdateAt time.Time + Latitude float64 + Longitude float64 + RegionId string + SelectCityCode string + SelectCityName string + type Page struct + Current int + PageSize int + Total int64 + type Pagination struct + ExData H + Limit int + Offset int + Rows any + func InitPagination(p *Page, maxSize int) *Pagination + func (p *Pagination) AddExData(key string, val any) + type PubSub struct + TopicMsgQueue chan *TopicMsg + Topics *sync.Map + func NewPubSub() *PubSub + func (a *PubSub) Pub(topicId string, data any) + func (a *PubSub) Start() + func (a *PubSub) Sub(topicId string, user *User) + func (a *PubSub) SubFunc(topicId string, f func(msg *TopicMsg)) + type Resource struct + CdnUrl string + ExtData datatypes.JSON + MimeType string + Path string + Scenes string + type Response struct + Ctx *ApiData + func NewResponse(g *gin.Context, httpCode int) *Response + func (r *Response) Send() + func (r *Response) WithData(data any) *Response + func (r *Response) WithError(e Error, err error) *Response + type Routers struct + func NewRouter() Routers + func (r Routers) Add(name string, fn ...HandlerFunc) + func (r Routers) Group(name string) IRouter + func (r Routers) Use(middleware ...HandlerFunc) IRouter + type Server struct + func NewServer(engine http.Handler) *Server + func (s *Server) Handler(fn http.HandlerFunc) + func (s *Server) Init() + func (s *Server) Run() + func (s *Server) SetDataPath(p string) + func (s *Server) SetIsDev(dev bool) + func (s *Server) SetPort(p string) + type Stack struct + func NewStack() *Stack + func (s *Stack) Len() int + func (s *Stack) Pop() any + func (s *Stack) Push(value any) + type Topic struct + Id string + PubSub *PubSub + SubHandlers sync.Map + SubUsers sync.Map + func (a *Topic) AddSubHandle(f func(msg *TopicMsg)) + func (a *Topic) AddSubUser(user *User) + func (a *Topic) ApplyFunc(msg *TopicMsg) + func (a *Topic) SendToSubUser(msg []byte) + type TopicMsg struct + Msg []byte + Ori any + TopicId string + type User struct + AppClients []*Client + Avatar *Resource + Ban *time.Time + CurrentWindowId string + GroupId string + Hub *Hubc + LastHeartbeatTime time.Time + Location *Location + Nickname string + OnlineStatus UserOnlineStatus + RoleId []uint + SubTopics map[string]*Topic + Suid string + SuperAdmin bool + Uid uint + func NewUser(uid string) *User + func (u *User) AddSubTopic(topic *Topic) int + func (u *User) AppClient(appId string) *Client + func (u *User) Banned(t time.Duration) *time.Time + func (u *User) IsBanned() (bool, *time.Time) + func (u *User) IsOnline() bool + func (u *User) SendMsg(msg []byte) + func (u *User) SendMsgToApp(appId string, msg []byte) + func (u *User) Unban() *time.Time + func (u *User) UnsubTopic(topicId string) int + type UserOnlineStatus byte + const UserStatusBusy + const UserStatusLeaving + const UserStatusOnline + type Value struct + func (v *Value) Bool() bool + func (v *Value) Duration() time.Duration + func (v *Value) Float32() float32 + func (v *Value) Float64() float64 + func (v *Value) Int() int + func (v *Value) Int16() int16 + func (v *Value) Int32() int32 + func (v *Value) Int64() int64 + func (v *Value) Int8() int8 + func (v *Value) Map() map[string]any + func (v *Value) Raw() any + func (v *Value) Slice() []any + func (v *Value) SliceInt() []int + func (v *Value) SliceString() []string + func (v *Value) String() string + func (v *Value) StringMap() map[string]string + func (v *Value) Time() time.Time + func (v *Value) Uint() uint + func (v *Value) Uint16() uint16 + func (v *Value) Uint32() uint32 + func (v *Value) Uint64() uint64 + func (v *Value) Uint8() uint8