Documentation
¶
Index ¶
- Variables
- func NormalizeNic(nic string) string
- type Chat
- type Config
- type Message
- type Room
- func (r *Room) BeatReceivedFrom(nic string)
- func (r *Room) GetSubscriber(nic string) (*subscriber, error)
- func (r *Room) HaveSubscriber(nic string) bool
- func (r *Room) NewIncomingMessageFrom(nic, msg string) error
- func (r *Room) PushArchivesTo(nic string)
- func (r *Room) PushMessage(from, msg string) error
- func (r *Room) PushMessageTo(msg, nic string)
- func (r *Room) Sub(nic string, ws *websocket.Conn) error
- func (r *Room) Unsub(nic string)
- func (r *Room) Watch()
- type RoomConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrRoomNotFound = errors.New("room not found")
ErrRoomNotFound when room is not found or doesn't exists
Functions ¶
func NormalizeNic ¶
NormalizeNic return a normalized version of nic cut to 10 char && tolower
Types ¶
type Chat ¶
type Chat struct {
// contains filtered or unexported fields
}
Chat represents a chat
func (*Chat) AddRoom ¶
func (c *Chat) AddRoom(name string, conf RoomConfig) (err error)
AddRoom add a new room
func (*Chat) RoomExists ¶
RoomExists checks if room exists
func (*Chat) WebsocketHandler ¶
WebsocketHandler handle webssocket conn
type Config ¶
type Config struct {
// log
Logger *log.Logger
// debug
Debug bool
// data path for storing data (archives, DB files, template....)
// default = appPath/data
DataPath string
}
Config represents global configuration for chat
type Room ¶
type Room struct {
// contains filtered or unexported fields
}
Room represents a romm
func (*Room) BeatReceivedFrom ¶
BeatReceivedFrom handle beat recived from subscriber
func (*Room) GetSubscriber ¶
GetSubscriber return subscriber... or not
func (*Room) HaveSubscriber ¶
HaveSubscriber check if nic is in chatroom
func (*Room) NewIncomingMessageFrom ¶
NewIncomingMessageFrom handle new message from nic
func (*Room) PushArchivesTo ¶
PushArchivesTo send archive to subscriber
func (*Room) PushMessage ¶
PushMessage push msg to all subscribers
func (*Room) PushMessageTo ¶
PushMessageTo send a message to nic
type RoomConfig ¶
type RoomConfig struct {
// do we have to archive this room
// Default: false
Archived bool
// number of archived Messages server will push to new subscriber
// Default 0
ArchivePushMessagesCount uint16
// if server do not recieve beat from sunscriber after this 2*delay (in sec)
// subscriber will be unsub
// Default 0
HeartRate uint16
}
RoomConfig is used to configure a new room
Click to show internal directories.
Click to hide internal directories.