feat: add midjourney message receive handler

This commit is contained in:
RockYang
2023-08-14 07:09:52 +08:00
parent 302cb8a5be
commit 6e40f92aaf
8 changed files with 54 additions and 31 deletions

View File

@@ -34,7 +34,7 @@ type AppServer struct {
ChatClients *types.LMap[string, *types.WsClient] // map[sessionId]Websocket 连接集合
ReqCancelFunc *types.LMap[string, context.CancelFunc] // HttpClient 请求取消 handle function
Functions map[string]function.Function
MjTasks *types.LMap[string, types.MjTask]
MjTaskClients *types.LMap[string, *types.WsClient]
}
func NewServer(appConfig *types.AppConfig, functions map[string]function.Function) *AppServer {
@@ -48,7 +48,7 @@ func NewServer(appConfig *types.AppConfig, functions map[string]function.Functio
ChatSession: types.NewLMap[string, types.ChatSession](),
ChatClients: types.NewLMap[string, *types.WsClient](),
ReqCancelFunc: types.NewLMap[string, context.CancelFunc](),
MjTasks: types.NewLMap[string, types.MjTask](),
MjTaskClients: types.NewLMap[string, *types.WsClient](),
Functions: functions,
}
}

View File

@@ -12,8 +12,8 @@ type BizVo struct {
// WsMessage Websocket message
type WsMessage struct {
Type WsMsgType `json:"type"` // 消息类别start, end
Content string `json:"content"`
Type WsMsgType `json:"type"` // 消息类别start, end, img
Content interface{} `json:"content"`
}
type WsMsgType string
@@ -21,6 +21,7 @@ const (
WsStart = WsMsgType("start")
WsMiddle = WsMsgType("middle")
WsEnd = WsMsgType("end")
WsImg = WsMsgType("img")
)
type BizCode int