Documentation
¶
Index ¶
- type Channel
- type ChannelRepository
- type Client
- type ClientRepository
- type ClientSender
- type Message
- type MessageRepository
- type Server
- func (s *Server) AddChannel(channel *Channel)
- func (s *Server) AddClient(client *Client) error
- func (s *Server) GetChannel(channelId int64) *Channel
- func (s *Server) GetChannels() map[int64]*Channel
- func (s *Server) GetClient(clientId int64) *Client
- func (s *Server) GetClients() map[int64]*Client
- func (s *Server) RemoveChannel(channelId int64)
- func (s *Server) RemoveClient(clientId int64) error
- type ServerRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Channel ¶
type Channel struct { Id int64 Name string Public bool Capacity int Clients []*Client Messages []*Message // contains filtered or unexported fields }
Chat channel Goroutine safe
func NewChannel ¶
type ChannelRepository ¶
type Client ¶
type Client struct { Id int64 DisplayName string FirstName string LastName string Email string Channel *Channel ClientSender ClientSender }
Client is a normal user of the chat service
type ClientRepository ¶
type ClientSender ¶
type ClientSender interface { Send(message *Message) ChannelCreated(channel *Channel) ChannelJoined(channel *Channel, client *Client) }
ClientSender is used to send information to the client
type Message ¶
type Message struct { Id int64 Body string ClientId int64 ChannelId int64 Author string Time time.Time }
Message
type MessageRepository ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server Goroutine safe
func (*Server) AddChannel ¶
AddChannel creates a channel in the server
func (*Server) GetChannel ¶
GetChannel returns the channel with channelId
func (*Server) GetChannels ¶
GetChannels returns a copy of the channels map
func (*Server) GetClients ¶
GetClients returns a copy of the clients map
func (*Server) RemoveChannel ¶
RemoveChannel deletes a channel in the server
func (*Server) RemoveClient ¶
RemoveClient removes a client from the server
type ServerRepository ¶
type ServerRepository interface {
Get() *Server
}
Click to show internal directories.
Click to hide internal directories.