package main

import (
	//	"fmt"

	//"../log"
	"../nnet"
	"../nt"
)

type LoginPacket struct {
	body []byte
}

func NewLoginPacket(b []byte) *LoginPacket {
	return &LoginPacket{
		body: b,
	}
}

func (self *LoginPacket) Serialize() []byte {
	return self.body
}

func (self *LoginPacket) Destroy(b []byte) {

}

func (self *LoginPacket) ShouldClose() (bool, int32) {
	return false, 0
}

type LoginProtocol struct {
}

func (self *LoginProtocol) ReadPacket(conn nnet.IConn) (nnet.IPacket, error) {
	buf := make([]byte, nt.DEF_MAX_NET_BUFFER)
	//var buf []byte
	n, err := conn.Read(buf)
	if err != nil {
		return nil, err
	}
	return NewLoginPacket(buf[:n]), nil
}
