1
This commit is contained in:
parent
1b28b28a3e
commit
d5d884b191
@ -11,15 +11,15 @@ import (
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
)
|
||||
|
||||
type WSPListener_ struct {
|
||||
type WSPListener struct {
|
||||
listener net.Listener
|
||||
ch chan *f5.MsgHdr
|
||||
msgList q5.ListHead
|
||||
}
|
||||
|
||||
var WSPListener = new (WSPListener_)
|
||||
var wspListener = new (WSPListener)
|
||||
|
||||
func (this *WSPListener_) Init() {
|
||||
func (this *WSPListener) Init() {
|
||||
this.ch = make(chan *f5.MsgHdr)
|
||||
listener, err := net.Listen("tcp", "0.0.0.0:8888")
|
||||
if err != nil {
|
||||
@ -31,10 +31,10 @@ func (this *WSPListener_) Init() {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *WSPListener_) UnInit() {
|
||||
func (this *WSPListener) UnInit() {
|
||||
}
|
||||
|
||||
func (this *WSPListener_) accept() {
|
||||
func (this *WSPListener) accept() {
|
||||
fmt.Println("accpet")
|
||||
for {
|
||||
conn, err := this.listener.Accept()
|
||||
@ -45,7 +45,7 @@ func (this *WSPListener_) accept() {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *WSPListener_) socketRead(conn net.Conn) {
|
||||
func (this *WSPListener) socketRead(conn net.Conn) {
|
||||
buf := make([]byte, 1024 * 64)
|
||||
recvBufLen := 0
|
||||
recvBuf := make([]byte, 1024 * 64 * 2)
|
||||
@ -96,7 +96,7 @@ func (this *WSPListener_) socketRead(conn net.Conn) {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *WSPListener_) decodePacket(conn net.Conn, buf []byte, offset *int, bufLen int) {
|
||||
func (this *WSPListener) decodePacket(conn net.Conn, buf []byte, offset *int, bufLen int) {
|
||||
warning := false
|
||||
for bufLen - *offset >= f5.WSPROXYPACKHEAD_C_SIZE {
|
||||
msgHead := f5.WSProxyPackHead_C{}
|
||||
@ -124,7 +124,7 @@ func (this *WSPListener_) decodePacket(conn net.Conn, buf []byte, offset *int, b
|
||||
}
|
||||
}
|
||||
|
||||
func (this *WSPListener_) parseNetPkt() {
|
||||
func (this *WSPListener) parseNetPkt() {
|
||||
for {
|
||||
if hdr, ok := <-this.ch; ok {
|
||||
hdr.Msg = cs.ParsePb(hdr.MsgId, hdr.Data)
|
||||
@ -136,7 +136,7 @@ func (this *WSPListener_) parseNetPkt() {
|
||||
}
|
||||
}
|
||||
|
||||
func (this *WSPListener_) sendProxyMsg(conn net.Conn, socketHandle uint16, msg proto.Message) {
|
||||
func (this *WSPListener) sendProxyMsg(conn net.Conn, socketHandle uint16, msg proto.Message) {
|
||||
netMsg := msg.(f5.NetMsg)
|
||||
msgData, err := proto.Marshal(msg)
|
||||
if err != nil {
|
||||
|
@ -28,13 +28,13 @@ func (this *App) Init() {
|
||||
this.workList.Init(nil)
|
||||
f5.LoadMetaTable(mt.Table)
|
||||
HandlerMgr.Init()
|
||||
WSPListener.Init()
|
||||
wspListener.Init()
|
||||
go this.goReportServerState()
|
||||
}
|
||||
|
||||
func (this *App) UnInit() {
|
||||
HandlerMgr.UnInit()
|
||||
WSPListener.UnInit()
|
||||
wspListener.UnInit()
|
||||
this.App_.UnInit()
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ func (this *App) Update() {
|
||||
if ok {
|
||||
handler := cs.GetNetMsgHandler(hdr.MsgId)
|
||||
if handler != nil && handler.HandlerId== PLAYER_MGR_HANDLER_ID {
|
||||
cs.DispatchMsg(handler, hdr, PlayerMgr)
|
||||
cs.DispatchMsg(handler, hdr, playerMgr)
|
||||
}
|
||||
}
|
||||
next.Del()
|
||||
|
@ -5,15 +5,15 @@ import (
|
||||
"f5"
|
||||
)
|
||||
|
||||
type PlayerMgr_ struct {
|
||||
type PlayerMgr struct {
|
||||
cs.MsgHandlerImpl
|
||||
}
|
||||
|
||||
var PlayerMgr = new (PlayerMgr_)
|
||||
var playerMgr = new (PlayerMgr)
|
||||
|
||||
func (this *PlayerMgr_) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
|
||||
func (this *PlayerMgr) CMLogin(hdr *f5.MsgHdr, msg *cs.CMLogin) {
|
||||
serverInfo := "192.168.100.39:1000"
|
||||
rspMsg := &cs.SMLogin{}
|
||||
rspMsg.ServerInfo = &serverInfo
|
||||
WSPListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||
wspListener.sendProxyMsg(hdr.Conn, hdr.SocketHandle, rspMsg)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user