Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidMessageType = errors.New("invalid message type") ErrInitUpload = errors.New("could not initialize upload") ErrResumeUpload = errors.New("could not resume upload") )
View Source
var (
ErrClosedByClient = errors.New("closed by client")
)
View Source
var OkMessage = Message{ Type: MsgTypeOk, }
Functions ¶
This section is empty.
Types ¶
type DataServiceInterface ¶
type DataServiceInterface interface {
NewUpload(identifier string, contentLength int, r io.Reader) error
ResumeUpload(identifier string, r io.Reader) error
GetUploadedBytes(identifier string) (int, error)
}
DataServiceInterface is an interface the websocket handler is prepared to receive.
type ErrorMessage ¶
func NewErrorMessage ¶
func NewErrorMessage(err error) ErrorMessage
type Handler ¶
type Handler struct {
W http.ResponseWriter
R *http.Request
FS DataServiceInterface
Timeout time.Duration
ErrCH chan error
// Delay between reading of successive messages.
// This gives time for the server to handle messages
// that are already in the system. This will typically be
// something like 10ms.
MessageDelay time.Duration
// contains filtered or unexported fields
}
Websocket handler.
func (*Handler) Handle ¶
Handle will implement the upload protocol. If an uploadId is provided it will assume that the upload is a continuing upload. Otherwise, it is a new upload.
Calling functions should assume that errors are already handled and that the connection will be closed on error. HOWEVER, in the case of success, the connection will *not* be closed. This way, the calling function can continue to send messages through this same connection.
Input error channel is to handle errors from the file service. The calling function can continue to send messages
type StartMessage ¶
type StatusMessage ¶
func NewStatusMessage ¶
func NewStatusMessage(uploaded int) StatusMessage
Click to show internal directories.
Click to hide internal directories.