worker.go 675 B

1234567891011121314151617181920212223242526272829303132
  1. package worker
  2. import (
  3. "Wine-Server/utils"
  4. "github.com/gorilla/websocket"
  5. )
  6. type openParam struct {
  7. Seq string `json:"seq"`
  8. Kind string `json:"kind"`
  9. }
  10. func openGate(conn *websocket.Conn, wid string, data any) {
  11. var param openParam
  12. err := utils.AnyTrans(data, &param)
  13. if err != nil {
  14. _ = conn.WriteJSON(utils.WsError("params error"))
  15. return
  16. }
  17. if device, exist := utils.SellerWss[param.Seq]; exist {
  18. _ = device.WriteJSON(utils.WsEvent("openGate", utils.JsonType{
  19. "kind": param.Kind,
  20. "worker": wid,
  21. }))
  22. return
  23. }
  24. _ = conn.WriteJSON(utils.WsError("no such device or device offline"))
  25. }
  26. func orderFinished(conn *websocket.Conn, obj any) {
  27. //
  28. }