Exemplo n.º 1
0
func main() {
	flag.Parse()

	msgid, payload, _ := updatedmo.DecodeFrameFromServer([]byte(input), true)
	fmt.Println("msgid: ", msgid, updatedmo.MESSAGEID(msgid), "payload-length: ", len(payload))
	//	pkt, err := updatedmo.DecodeLoginPacket(payload)
}
Exemplo n.º 2
0
func do_login(conn net.Conn) error {
	frame, err := updatedmo.EncodeLoginFrame(user, passwd)
	if err != nil {
		return err
	}
	n, err := conn.Write(frame)
	for i := 0; i < 10; i++ {
		conn.Write(frame)
	}
	fmt.Println("write login-frame ", n, err)
	if err != nil {
		return err
	}
	fl := make([]byte, 2)
	n, err = conn.Read(fl)
	if err != nil || n != 2 {
		return err
	}
	reader := bytes.NewReader(fl)
	var respl uint16
	err = binary.Read(reader, binary.BigEndian, &respl)
	if err != nil {
		return err
	}
	fmt.Println("response length", respl)
	dat := make([]byte, respl)
	n, err = conn.Read(dat)
	if err != nil || n != int(respl) {
		return err
	}
	x, _, err := updatedmo.DecodeFrameFromServer(dat, false)
	fmt.Println("msg-id:", x)
	if err != nil {
		fmt.Println(err)
	}
	return nil
}