提交 0918aca1 编写于 作者: J Jason

提取了 Client接口,避免循环引入

上级 ed1e8c4d
package base
import "github.com/zgwit/dtu-admin/packet"
type Client interface {
CLose() error
Send(msg *packet.Packet) error
Write(b []byte) error
Handle(msg *packet.Packet)
}
package dbus
import (
"github.com/zgwit/dtu-admin/base"
"github.com/zgwit/dtu-admin/packet"
"log"
"net"
"time"
)
type Client interface {
CLose() error
Send(msg *packet.Packet) error
Write(b []byte) error
handle(msg *packet.Packet)
}
type baseClient struct {
conn net.Conn
}
......@@ -47,7 +41,7 @@ func (p *baseClient) Write(b []byte) error {
return nil
}
func NewClient() Client {
func NewClient() base.Client {
//根据类型
return nil
}
\ No newline at end of file
package dbus
import (
"github.com/zgwit/dtu-admin/dtu"
"github.com/zgwit/dtu-admin/packet"
"log"
)
......@@ -9,10 +10,10 @@ import (
type Peer struct {
baseClient
//link *dtu.Link
link *dtu.Link
}
func (p *Peer) handle(msg *packet.Packet) {
func (p *Peer) Handle(msg *packet.Packet) {
switch msg.Type {
case packet.TypeConnect:
p.handleConnect(msg)
......
......@@ -9,7 +9,7 @@ type Plugin struct {
baseClient
}
func (p *Plugin) handle(msg *packet.Packet) {
func (p *Plugin) Handle(msg *packet.Packet) {
switch msg.Type {
case packet.TypeConnect:
p.handleConnect(msg)
......
......@@ -64,7 +64,7 @@ func (s *Server) receive(conn net.Conn) {
}
packs := parser.Parse(buf[:n])
for _, pack := range packs {
c.handle(pack)
c.Handle(pack)
}
}
......
......@@ -4,7 +4,6 @@ import (
"errors"
"github.com/zgwit/dtu-admin/base"
"github.com/zgwit/dtu-admin/db"
"github.com/zgwit/dtu-admin/dbus"
"github.com/zgwit/dtu-admin/model"
"github.com/zgwit/dtu-admin/packet"
"log"
......@@ -25,9 +24,9 @@ type Link struct {
cache [][]byte
//透传链接
peer dbus.Client
peer base.Client
plugin dbus.Client
plugin base.Client
//监视器连接,
monitor *Monitor
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册