Documentation ¶
Index ¶
- Constants
- func GetStartupChoice(choices []string) int
- func RegisterStructs()
- func SendRemoteCommand(encoder *gob.Encoder, message Message) error
- type AuthenticateMessage
- type COMMAND
- type ChatClient
- func (client *ChatClient) Authenticate(username string, password string) error
- func (client *ChatClient) BuildCloseRoomMessage(room string) (Message, error)
- func (client *ChatClient) BuildCreateRoomMessage(room string, capacity int) (Message, error)
- func (client *ChatClient) BuildJoinRoomMessage(room string) (Message, error)
- func (client *ChatClient) BuildLeaveRoomMessage(room string) (Message, error)
- func (client *ChatClient) BuildListRoomsMessage() (Message, error)
- func (client *ChatClient) BuildPopulateMessage(roomName string, timeSince time.Time) (Message, error)
- func (client *ChatClient) BuildSendMessageMessage(content string, room string) (Message, error)
- func (client *ChatClient) Connect(connection_string string) error
- func (client *ChatClient) DisplayPopulateMessages(message PopulateMessages)
- func (client *ChatClient) DisplayRoomListingMessage(message ListRoomsMessage)
- func (client *ChatClient) DisplayTextMessage(message TextMessage)
- func (client *ChatClient) EventLoop(server_messages <-chan Message, client_messages <-chan Message, ...)
- func (client *ChatClient) HandleServerMessage(message Message) error
- func (client *ChatClient) ListenToServer(notify chan<- Message, exit <-chan int, auth chan<- bool) error
- func (client *ChatClient) ListenToUser(message_channel chan<- Message) error
- func (client *ChatClient) Register(username string, password string) error
- type ChatServer
- type CloseRoomMessage
- type CreateRoomMessage
- type DatabaseConfig
- type JoinRoomMessage
- type LeaveRoomMessage
- type ListRoomsMessage
- type Message
- type PopulateMessages
- type RecvTextMessage
- type RegisterMessage
- type Room
- type RoomManager
- func (manager *RoomManager) CloseRoom(name string) (*ServerRoom, error)
- func (manager *RoomManager) CreateRoom(name string, capacity int) (*ServerRoom, error)
- func (manager *RoomManager) GetRoom(name string) (*ServerRoom, error)
- func (manager *RoomManager) GetRoomNames() []string
- func (manager *RoomManager) LoadRooms() error
- type RoomMessage
- type RoomMessageManager
- type STATUS
- type SendTextMessage
- type ServerConfig
- type ServerRoom
- type ServerRoomMessage
- type ServerUser
- type StorageManager
- func (manager *StorageManager) CheckExecOutcome(result driver.Result, err error, affectedCheck func(int64) bool) error
- func (manager *StorageManager) CloseStorage() error
- func (manager *StorageManager) ExecAtLeastOneRow(result driver.Result, err error) error
- func (manager *StorageManager) ExecOneRow(result driver.Result, err error) error
- func (manager *StorageManager) ExecZeroOrMoreRows(result driver.Result, err error) error
- type TextMessage
- type TokenMessage
- type User
- type UserManager
- func (manager *UserManager) AuthenticateUser(username string, password_sha256 string) (*ServerUser, error)
- func (manager *UserManager) CreateUser(username string, password string) error
- func (manager *UserManager) DeleteUser(username string) error
- func (manager *UserManager) GetUser(username string) (*ServerUser, error)
- func (manager *UserManager) TokenIsValid(token string) (bool, error)
- func (manager *UserManager) UpdatePassword(username string, password string) error
Constants ¶
View Source
const ( REGISTER = COMMAND("Register") AUTHENTICATE = COMMAND("Authenticate") TOKEN = COMMAND("Token") LIST_ROOMS = COMMAND("List Rooms") JOIN_ROOM = COMMAND("Join Room") LEAVE_ROOM = COMMAND("Leave Room") CREATE_ROOM = COMMAND("Create Room") CLOSE_ROOM = COMMAND("Close Room") SEND_MSG = COMMAND("Send Message") RECV_MSG = COMMAND("Receive Message") POP_MSGS = COMMAND("Populate Messages") )
View Source
const ( SUCCESS = STATUS("Request was successfull") FAILURE = STATUS("Request failed") )
View Source
const ( CREATE_ROOM_SQL = "INSERT INTO rooms (name, capacity, closed) VALUES (?, ?, ?)" GET_ALL_ROOMS_SQL = "SELECT * FROM rooms WHERE closed=?" DELETE_ROOM_SQL = "DELETE FROM rooms WHERE name=?" GET_ROOM_SQL = "SELECT * FROM rooms WHERE name=?" ROOM_SCHEMA = `` /* 136-byte string literal not displayed */ )
View Source
const ( CREATE_MESSAGE_SQL = "INSERT INTO messages (user_id, room_id, message, epoch_timestamp) VALUES (?, ?, ?, ?)" GET_LATEST_ROOM_MESSAGES = `` /* 219-byte string literal not displayed */ MESSAGE_SCHEMA = `` /* 158-byte string literal not displayed */ )
View Source
const ( TOKEN_LENGTH = 12 TOKEN_LETTERS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" )
View Source
const ( CREATE_USER_SQL = "INSERT INTO users (username, salt, password_sha256, Deleted) VALUES (?, ?, ?, ?)" UPDATE_PASSWORD_SQL = "UPDATE users SET salt=?, password_sha256=? WHERE username=?" DELETE_USER_SQL = "UPDATE users SET deleted=true WHERE username=?" GET_USER_SQL = "SELECT * FROM users WHERE username=? AND deleted=?" USER_SCHEMA = `` /* 158-byte string literal not displayed */ )
View Source
const (
SALT_BYTES = 64
)
Variables ¶
This section is empty.
Functions ¶
func GetStartupChoice ¶
func RegisterStructs ¶
func RegisterStructs()
Types ¶
type AuthenticateMessage ¶
type ChatClient ¶
type ChatClient struct {
// contains filtered or unexported fields
}
func NewChatClient ¶
func NewChatClient(logger *log.Entry) (*ChatClient, error)
func (*ChatClient) Authenticate ¶
func (client *ChatClient) Authenticate(username string, password string) error
func (*ChatClient) BuildCloseRoomMessage ¶
func (client *ChatClient) BuildCloseRoomMessage(room string) (Message, error)
func (*ChatClient) BuildCreateRoomMessage ¶
func (client *ChatClient) BuildCreateRoomMessage(room string, capacity int) (Message, error)
func (*ChatClient) BuildJoinRoomMessage ¶
func (client *ChatClient) BuildJoinRoomMessage(room string) (Message, error)
func (*ChatClient) BuildLeaveRoomMessage ¶
func (client *ChatClient) BuildLeaveRoomMessage(room string) (Message, error)
func (*ChatClient) BuildListRoomsMessage ¶
func (client *ChatClient) BuildListRoomsMessage() (Message, error)
func (*ChatClient) BuildPopulateMessage ¶
func (*ChatClient) BuildSendMessageMessage ¶
func (client *ChatClient) BuildSendMessageMessage(content string, room string) (Message, error)
func (*ChatClient) Connect ¶
func (client *ChatClient) Connect(connection_string string) error
func (*ChatClient) DisplayPopulateMessages ¶
func (client *ChatClient) DisplayPopulateMessages(message PopulateMessages)
func (*ChatClient) DisplayRoomListingMessage ¶
func (client *ChatClient) DisplayRoomListingMessage(message ListRoomsMessage)
func (*ChatClient) DisplayTextMessage ¶
func (client *ChatClient) DisplayTextMessage(message TextMessage)
func (*ChatClient) EventLoop ¶
func (client *ChatClient) EventLoop(server_messages <-chan Message, client_messages <-chan Message, exit <-chan int)
func (*ChatClient) HandleServerMessage ¶
func (client *ChatClient) HandleServerMessage(message Message) error
func (*ChatClient) ListenToServer ¶
func (client *ChatClient) ListenToServer(notify chan<- Message, exit <-chan int, auth chan<- bool) error
func (*ChatClient) ListenToUser ¶
func (client *ChatClient) ListenToUser(message_channel chan<- Message) error
type ChatServer ¶
type ChatServer struct {
// contains filtered or unexported fields
}
func NewChatServer ¶
func NewChatServer(logger *log.Entry, config ServerConfig) (*ChatServer, error)
func (*ChatServer) HandleIncomingConnection ¶
func (server *ChatServer) HandleIncomingConnection(connection net.Conn)
func (*ChatServer) HandleMessage ¶
func (ChatServer) Listen ¶
func (server ChatServer) Listen(connection_string string) error
type CloseRoomMessage ¶
type CreateRoomMessage ¶
type DatabaseConfig ¶
type JoinRoomMessage ¶
type LeaveRoomMessage ¶
type LeaveRoomMessage struct { Username string Room string Token string Status STATUS Message TextMessage }
type ListRoomsMessage ¶
type ListRoomsMessage struct {
Rooms []string
}
type PopulateMessages ¶
type PopulateMessages struct { Room string Messages []TextMessage TimeSince int Limit int Token string }
type RecvTextMessage ¶
type RecvTextMessage struct {
Message TextMessage
}
type RegisterMessage ¶
type RoomManager ¶
type RoomManager struct {
// contains filtered or unexported fields
}
func NewRoomManager ¶
func NewRoomManager(storage *StorageManager, logger *log.Entry) (*RoomManager, error)
func (*RoomManager) CloseRoom ¶
func (manager *RoomManager) CloseRoom(name string) (*ServerRoom, error)
func (*RoomManager) CreateRoom ¶
func (manager *RoomManager) CreateRoom(name string, capacity int) (*ServerRoom, error)
func (*RoomManager) GetRoom ¶
func (manager *RoomManager) GetRoom(name string) (*ServerRoom, error)
func (*RoomManager) GetRoomNames ¶
func (manager *RoomManager) GetRoomNames() []string
func (*RoomManager) LoadRooms ¶
func (manager *RoomManager) LoadRooms() error
type RoomMessage ¶
type RoomMessageManager ¶
type RoomMessageManager struct {
// contains filtered or unexported fields
}
func NewRoomMessageManager ¶
func NewRoomMessageManager(storageManager *StorageManager, roomManager *RoomManager, userManager *UserManager, logger *log.Entry) (*RoomMessageManager, error)
func (*RoomMessageManager) GetRoomMessagesSince ¶
func (manager *RoomMessageManager) GetRoomMessagesSince(room *ServerRoom, timeSince time.Time, limit int) ([]TextMessage, error)
func (*RoomMessageManager) PersistRoomMessage ¶
func (manager *RoomMessageManager) PersistRoomMessage(user *ServerUser, room *ServerRoom, message string) error
type SendTextMessage ¶
type SendTextMessage struct { Token string Message TextMessage }
type ServerConfig ¶
type ServerConfig struct {
Database DatabaseConfig `yaml:"database"`
}
func LoadServerConfigurationFile ¶
func LoadServerConfigurationFile(filename string) (ServerConfig, error)
type ServerRoom ¶
type ServerRoom struct { Room *Room // contains filtered or unexported fields }
func (*ServerRoom) AddUser ¶
func (room *ServerRoom) AddUser(user *ServerUser) error
func (*ServerRoom) RemoveUser ¶
func (room *ServerRoom) RemoveUser(user *ServerUser) error
func (*ServerRoom) String ¶
func (room *ServerRoom) String() string
type ServerRoomMessage ¶
type ServerRoomMessage struct { RoomMessage *RoomMessage Room *ServerRoom User *ServerUser Timestamp time.Time }
func (*ServerRoomMessage) String ¶
func (message *ServerRoomMessage) String() string
type ServerUser ¶
type ServerUser struct { User *User // contains filtered or unexported fields }
func (*ServerUser) GetToken ¶
func (user *ServerUser) GetToken() string
func (*ServerUser) String ¶
func (user *ServerUser) String() string
type StorageManager ¶
type StorageManager struct {
// contains filtered or unexported fields
}
func NewStorageManager ¶
func NewStorageManager(config DatabaseConfig, logger *log.Entry) (*StorageManager, error)
func (*StorageManager) CheckExecOutcome ¶
func (manager *StorageManager) CheckExecOutcome(result driver.Result, err error, affectedCheck func(int64) bool) error
Convenience wrapper around the DB's Exec call result, it returns any errors Exec encounters It also has an affectedCheck anon function that ensure the correct number of rows is affected
func (*StorageManager) CloseStorage ¶
func (manager *StorageManager) CloseStorage() error
func (*StorageManager) ExecAtLeastOneRow ¶
func (manager *StorageManager) ExecAtLeastOneRow(result driver.Result, err error) error
func (*StorageManager) ExecOneRow ¶
func (manager *StorageManager) ExecOneRow(result driver.Result, err error) error
func (*StorageManager) ExecZeroOrMoreRows ¶
func (manager *StorageManager) ExecZeroOrMoreRows(result driver.Result, err error) error
type TextMessage ¶
type TokenMessage ¶
type UserManager ¶
type UserManager struct {
// contains filtered or unexported fields
}
func NewUserManager ¶
func NewUserManager(storage *StorageManager, logger *log.Entry) (*UserManager, error)
func (*UserManager) AuthenticateUser ¶
func (manager *UserManager) AuthenticateUser(username string, password_sha256 string) (*ServerUser, error)
func (*UserManager) CreateUser ¶
func (manager *UserManager) CreateUser(username string, password string) error
func (*UserManager) DeleteUser ¶
func (manager *UserManager) DeleteUser(username string) error
func (*UserManager) GetUser ¶
func (manager *UserManager) GetUser(username string) (*ServerUser, error)
func (*UserManager) TokenIsValid ¶
func (manager *UserManager) TokenIsValid(token string) (bool, error)
func (*UserManager) UpdatePassword ¶
func (manager *UserManager) UpdatePassword(username string, password string) error
Click to show internal directories.
Click to hide internal directories.