Documentation
¶
Index ¶
- Constants
- type ChatMessage
- type Event
- type JSONStringMap
- func (JSONStringMap) GormDBDataType(db *gorm.DB, field *schema.Field) string
- func (m JSONStringMap) GormDataType() string
- func (m JSONStringMap) MarshalJSON() ([]byte, error)
- func (m *JSONStringMap) Scan(val interface{}) error
- func (m *JSONStringMap) UnmarshalJSON(b []byte) error
- func (m JSONStringMap) Value() (driver.Value, error)
- type LoginMessage
- type Room
- type Source
- type TagUpdate
- type User
- type WebsocketMessage
- type WireEvent
Constants ¶
const ( EventTypeInfo = "info" EventTypeChat = "chat" EventTypeCommand = "command" EventTypeUser = "user" EventTypeTranslation = "translation" EventTypeInternal = "_internal" )
const ( WireMessageTypeInfo = "info" WireMessageTypeChat = "chat" WireMessageTypeLogin = "login" WireMessageTypeLogout = "logout" WireMessageTypeUser = "user" WireMessageTypeTranslation = "translation" WireMessageTypeCommand = "command" WireMessageTypeGeneric = "generic" WireMessageTypeChats = "chats" WireMessageTypeTranslations = "translations" WireMessageTypeUsers = "users" WireMessageTypeCommands = "commands" WireMessageTypeGenerics = "generics" )
const ( TagValueTypeString = 0 TagValueTypeInt = 1 TagValueTypeFloat = 2 TagValueTypeStringSlice = 3 TagValueTypeIntSlice = 4 TagValueTypeFloatSlice = 5 )
Make sure those constants are the same as defined in the proto enum!
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatMessage ¶
type ChatMessage struct { Nick string `json:"nick" mapstructure:"-"` // sender nick, outgoing Timestamp time.Time `json:"timestamp" mapstructure:"-"` // sent time, outgoing Message string `json:"message" mapstructure:"message"` // actual message, incoming + outgoing Language string `json:"language" hash:"ignore" mapstructure:"-"` // language of the message (for future use), outgoing Filter string `json:"filter" mapstructure:"filter"` // filter expression incoming }
ChatMessage is a basic chat message, contains the sender nick
type Event ¶
type Event struct { Id string `json:"id" hash:"ignore" gorm:"primaryKey"` RoomId string `json:"-"` Room *Room `json:"room"` *Source `json:"source" gorm:"embeddedPrefix:source_"` Created time.Time `json:"created" gorm:"autoCreateTime;index"` Language string `json:"language"` Name string `json:"name"` Tags JSONStringMap `json:"tags"` History bool `json:"history" gorm:"-"` // set to true is this event is sent from history // the following fields are not part of the filter.Env! Sent time.Time `json:"sent" hash:"ignore"` TargetFilter string `json:"target_filter"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` }
type JSONStringMap ¶
JSONStringMap defined JSON data type, need to implements driver.Valuer, sql.Scanner interface
func (JSONStringMap) GormDBDataType ¶
GormDBDataType gorm db data type
func (JSONStringMap) GormDataType ¶
func (m JSONStringMap) GormDataType() string
GormDataType gorm common data type
func (JSONStringMap) MarshalJSON ¶
func (m JSONStringMap) MarshalJSON() ([]byte, error)
MarshalJSON to output non base64 encoded []byte
func (*JSONStringMap) Scan ¶
func (m *JSONStringMap) Scan(val interface{}) error
Scan scan value into Jsonb, implements sql.Scanner interface
func (*JSONStringMap) UnmarshalJSON ¶
func (m *JSONStringMap) UnmarshalJSON(b []byte) error
UnmarshalJSON to deserialize []byte
type LoginMessage ¶
type LoginMessage struct { IdToken string `json:"id_token" mapstructure:"id_token"` Provider string `json:"provider" mapstructure:"provider"` Language string `json:"language" mapstructure:"language"` }
LoginMessage is sent when a client logs in and contains the id token, the provider and the user's language setting
type Room ¶
type Room struct { Id string `json:"id" gorm:"primaryKey"` OwnerId string `json:"-"` Owner *User `json:"owner"` Tags JSONStringMap `json:"tags"` // tags CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` // contains filtered or unexported fields }
this is basically identified with one hub, it is just a logical separation
type TagUpdate ¶
type TagUpdate struct { Name string `json:"name"` // tag name Type int `json:"type"` // type - TagValueType* const Index int `json:"index"` // used for slice types Expression string `json:"expression"` // expr expression to apply to the Tags, the tag "Name" is set to the resulting value }
a slice of TagUpdate objects is used for atomically updating Tags values (users/rooms/...)
type User ¶
type User struct { Id string `json:"id" gorm:"primaryKey"` // unique id Nick string `json:"nick" gorm:"index"` // should also be unique Language string `json:"language"` // alpha-2 iso Tags JSONStringMap `json:"tags"` // tags LastOnline time.Time `json:"last_online" hash:"ignore"` // last seen online CreatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"` DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` }
type WebsocketMessage ¶
type WebsocketMessage struct { Event string `json:"event"` Data json.RawMessage `json:"data"` }
JSON-serialized WebsocketMessage is what is actually sent via the Websocket connection