Refactor and simplify package structure and interfaces.

Reorganize code by removing unused files, restructuring package organization, and updating import references to new paths. This simplifies handling of smart and protocol-related operations, improves maintainability, and eliminates redundancy.
This commit is contained in:
2025-04-27 17:05:45 +03:00
parent 51308a2395
commit eaaa634558
24 changed files with 565 additions and 416 deletions

33
pkg/smart/scheme.go Normal file
View File

@ -0,0 +1,33 @@
package smart
import (
"gitea.unprism.ru/KRBL/n9m/v2/pkg/models"
"gitea.unprism.ru/KRBL/n9m/v2/pkg/protocol"
"net"
"sync"
)
type ProcessFunc func(*SmartPackage, protocol.Package) error
type AlarmProcessFunc func(*SmartPackage, protocol.Package, models.SendAlarmInfoResponse) error
type SmartPackage struct {
pack protocol.Package
conn net.Conn
buff []byte
payloadProcess map[protocol.PayloadType]ProcessFunc
jsonProcess map[string]ProcessFunc
alarmProcess map[protocol.AlarmType]AlarmProcessFunc
Storage map[string]interface{}
}
type SmartChannelPackage struct {
pack *SmartPackage
mainPack *SmartPackage
channelName string
mutex sync.RWMutex
ssrc map[uint16][]func([]byte) error
}