s2c.go 866 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package gatewayServer
  2. import (
  3. "errors"
  4. "fmt"
  5. )
  6. // 查询
  7. func s2c8003Query(devId string, subCode CmdCode, data string) error {
  8. a := AppDataUnit{
  9. CmdCode: CmdCodeGetParamS2C,
  10. SubCode: subCode,
  11. DevId: devId,
  12. }
  13. a.Debug()
  14. c, ok := ConnMap[devId]
  15. if !ok {
  16. return errors.New("连接不在cMap中")
  17. }
  18. _, err := c.Write(Pack(a))
  19. if err != nil {
  20. return err
  21. }
  22. return nil
  23. }
  24. var sp = "add=name:isapi;proto:tcp;src_dport:8848;dest_ip:192.168.1.64;dest_port:80"
  25. // 配置
  26. func s2c8004Set(devId string, subCode CmdCode, data string) error {
  27. a := AppDataUnit{
  28. CmdCode: CmdCodeSetParameterS2C,
  29. SubCode: subCode,
  30. DevId: devId,
  31. Data: data,
  32. }
  33. a.Debug()
  34. c, ok := ConnMap[devId]
  35. if !ok {
  36. return errors.New("连接不在cMap中")
  37. }
  38. fmt.Println("!!!!!!!!!!!!!!!")
  39. _, err := c.Write(Pack(a))
  40. if err != nil {
  41. return err
  42. }
  43. return nil
  44. }