Example #1
0
func NewEsServer() *esserver {

	server := &esserver{

		codec:      es.NewLiteMsgParse(),
		dispatch:   es.NewMsgDispatcher(),
		msgFactory: es.NewMsgFactory(),
		tcpServer:  es.NewTcpServer(),
	}

	server.codec.SetMsgFactory(server.msgFactory)

	server.tcpServer.SetMsgParse(server.codec)
	server.tcpServer.SetMsgDispather(server.dispatch)

	return server
}
Example #2
0
func main() {

	elog.InitLog(elog.INFO)
	tcpServer, err := es.NewTcpServer()
	if err != nil {
		elog.LogInfo("crate tcp socket fail ")
	}

	ch := make(chan os.Signal)
	signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM)

	fmt.Println(" begin listen....")
	tcpServer.Listen("0.0.0.0:6798")

	tcpServer.Run()
	fmt.Println(" begin listen....")

	fmt.Println(<-ch)

	tcpServer.Exit()

	elog.LogSys("Hhhhhh")

}