u
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
package websocket
|
||||
|
||||
type Outputer interface {
|
||||
Broadcast(v Response)
|
||||
Single(userID string, v Response)
|
||||
}
|
||||
@@ -1,47 +1,20 @@
|
||||
package websocket
|
||||
|
||||
type MessageType string
|
||||
type RequestType string
|
||||
|
||||
var (
|
||||
TypeOutput MessageType = "Output"
|
||||
TypeStreamNextVideo MessageType = "StreamNextVideo"
|
||||
TypeStreamPrevVideo MessageType = "StreamPrevVideo"
|
||||
TypeGetCurrentVideoPath MessageType = "GetCurrentVideoPath"
|
||||
TypeGetVideoList MessageType = "GetVideoList"
|
||||
TypeQuit MessageType = "Quit"
|
||||
TypeRemoveVideo MessageType = "RemoveVideo"
|
||||
TypeAddVideo MessageType = "AddVideo"
|
||||
const (
|
||||
TypeStreamNextVideo RequestType = "StreamNextVideo"
|
||||
TypeStreamPrevVideo RequestType = "StreamPrevVideo"
|
||||
TypeQuit RequestType = "Quit"
|
||||
)
|
||||
|
||||
type Request struct {
|
||||
Type MessageType `json:"type"`
|
||||
Args []string `json:"args"`
|
||||
UserID string `json:"user_id"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Type RequestType `json:"type"`
|
||||
}
|
||||
|
||||
type Response struct {
|
||||
Type MessageType `json:"type"`
|
||||
Success bool `json:"success"`
|
||||
Data any `json:"data"`
|
||||
Message string `json:"message"`
|
||||
UserID string `json:"user_id"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
func MakeResponse(messageType MessageType, success bool, data any, message string) Response {
|
||||
return Response{
|
||||
Type: messageType,
|
||||
Success: success,
|
||||
Data: data,
|
||||
Message: message,
|
||||
}
|
||||
}
|
||||
|
||||
func MakeOutput(output string) Response {
|
||||
return Response{
|
||||
Success: true,
|
||||
Type: TypeOutput,
|
||||
Data: output,
|
||||
}
|
||||
type Date struct {
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
CurrentVideoPath string `json:"currentVideoPath"`
|
||||
VideoList []string `json:"videoList"`
|
||||
Output string `json:"output"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user