Esempio n. 1
0
func handleConnection(conn *net.TCPConn) {
	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err)
			return
		}
	}()

	handler := NewHandler()
	handler.OnConnected(conn)
	defer handler.OnDisconnected()

	accu := lendecoder.NewAccumulator(handler, 2, 1200)
	err := accu.ReadFrom(conn)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
	}
}
Esempio n. 2
0
func handleConnection(conn *net.TCPConn) {
	defer conn.Close()
	defer func() {
		if err := recover(); err != nil {
			fmt.Println(err)
			return
		}
	}()

	conn.SetKeepAlive(true)
	conn.SetReadBuffer(4096)
	conn.SetWriteBuffer(4096)
	handler := NewHandler(conn)

	accu := lendecoder.NewAccumulator(handler, 2, 1200)
	err := accu.ReadFrom(conn)
	if err != nil {
		fmt.Printf("Error: %v\n", err)
	}
}