mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-05 21:18:30 -04:00
core: migrate to dankgo shared go modules, embed quickshell in DMS
binary to mount at runtime, -c or DMS_SHELL_DIR overrides required to explicitly override embedded configuration
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net"
|
||||
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/log"
|
||||
"github.com/AvengeMedia/DankMaterialShell/core/internal/server/params"
|
||||
"github.com/AvengeMedia/dankgo/ipc"
|
||||
"github.com/AvengeMedia/dankgo/ipc/params"
|
||||
)
|
||||
|
||||
type Conn = ipc.ConnWriter
|
||||
|
||||
func NewConn(c net.Conn) *Conn { return ipc.NewConnWriter(c) }
|
||||
|
||||
type Request struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
Method string `json:"method"`
|
||||
@@ -29,15 +33,13 @@ type Response[T any] struct {
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
|
||||
func RespondError(conn net.Conn, id int, errMsg string) {
|
||||
func RespondError(conn *Conn, id int, errMsg string) {
|
||||
log.Errorf("DMS API Error: id=%d error=%s", id, errMsg)
|
||||
resp := Response[any]{ID: id, Error: errMsg}
|
||||
json.NewEncoder(conn).Encode(resp)
|
||||
_ = conn.WriteResponse(Response[any]{ID: id, Error: errMsg})
|
||||
}
|
||||
|
||||
func Respond[T any](conn net.Conn, id int, result T) {
|
||||
resp := Response[T]{ID: id, Result: &result}
|
||||
json.NewEncoder(conn).Encode(resp)
|
||||
func Respond[T any](conn *Conn, id int, result T) {
|
||||
_ = conn.WriteResponse(Response[T]{ID: id, Result: &result})
|
||||
}
|
||||
|
||||
type SuccessResult struct {
|
||||
|
||||
Reference in New Issue
Block a user