This commit is contained in:
suyl
2021-06-28 18:51:29 +08:00
parent 274b9c7cba
commit fabdf33a3a
4 changed files with 7 additions and 14 deletions

View File

@@ -7,7 +7,6 @@ import (
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals"
"github.com/astaxie/beego/client/orm"
"io"
"net"
"strconv"
@@ -48,12 +47,7 @@ type TcpClient struct {
s *sync.RWMutex
}
func Init() {
listenTcp()
go handleTcpMessages()
}
func listenTcp() {
func ListenTcp() {
tcpClient.Clients = make(map[string]net.Conn)
l, err := net.Listen("tcp", ":8000")
if err != nil {
@@ -76,7 +70,6 @@ func handleConn(c net.Conn) {
printNo string //打印机编号
db = dao.GetDB()
)
db.Db = orm.NewOrmUsingDB("api") //读写这个库
if c == nil {
globals.SugarLogger.Debugf("conn is nil")
return
@@ -145,14 +138,13 @@ func changePrintMsg(db *dao.DaoDB, data string) (err error) {
return err
}
func handleTcpMessages() {
func HandleTcpMessages() {
var (
db = dao.GetDB()
offset, pageSize = 0, 10
c net.Conn
data []byte
)
db.Db = orm.NewOrmUsingDB("api") //读写这个库
for {
//一直读?
var err error