Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶
type Conn interface { Authorize() error GetConversant() repositories.Conversant Requests() chan Request Response() chan Response Leave() chan struct{} }
Conn is the generic connection interface that allows multiple connections to talk to each other over any protocol
type CreateConversationRequest ¶
type CreateConversationRequest struct { SenderID string `json:"-"` Name string `json:"name"` Conversants []string `json:"conversants"` }
CreateConversationRequest takes in a name and list of extra users to add to the conversation. SenderID is for internal use only, and should not be marshalled
func (CreateConversationRequest) Validate ¶
func (request CreateConversationRequest) Validate() error
type MockConn ¶
type MockConn struct { Auth func() error Conversant func() repositories.Conversant Request func() chan Request Resp func() chan Response Leaver func() chan struct{} }
func (*MockConn) GetConversant ¶
func (mock *MockConn) GetConversant() repositories.Conversant
type NewMessageResponse ¶
type NewMessageResponse struct {
repositories.Message
}
type Request ¶
type Request struct { Type RequestType `json:"type"` Data interface{} `json:"data"` }
Request is a struct with a dynamic body, with a specific type that allows the MUX to figure out how to cast the body
type RequestType ¶
type RequestType int
const ( SendMessage RequestType = iota CreateConversation RetrieveConversation RequestError )
type Response ¶
type Response struct { Type ResponseType `json:"type"` Data interface{} `json:"data"` }
func NewResponseError ¶
type ResponseError ¶
type ResponseError struct {
Error string `json:"error"`
}
type ResponseType ¶
type ResponseType int
const ( Error ResponseType = iota NewMessage NewConversation ReturnConversation )
type RetrieveConversationRequest ¶
type RetrieveConversationRequest struct { ConversationID string `json:"conversationId"` Limit int `json:"limit"` Offset int `json:"offset"` }
RetrieveConversationRequest uses a limit offset pattern in order to return chats from a conversation
func (RetrieveConversationRequest) Validate ¶
func (request RetrieveConversationRequest) Validate() error
type SendMessageRequest ¶
type SendMessageRequest struct { SenderID string `json:"-"` Message string `json:"message"` ConversationID string `json:"conversationId"` }
SendMessageRequest takes the message and conversation ID and sends the given message to the conversation
func (SendMessageRequest) Validate ¶
func (request SendMessageRequest) Validate() error
Click to show internal directories.
Click to hide internal directories.