2018-07-27 16:55:06 +03:00
|
|
|
package rfb
|
2017-06-26 18:21:15 +03:00
|
|
|
|
|
|
|
import "encoding/binary"
|
|
|
|
|
|
|
|
// DesktopNamePseudoEncoding represents a desktop size message from the server.
|
|
|
|
type DesktopNamePseudoEncoding struct {
|
|
|
|
Name []byte
|
|
|
|
}
|
|
|
|
|
2017-07-14 02:01:24 +03:00
|
|
|
func (*DesktopNamePseudoEncoding) Supported(Conn) bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2017-06-26 18:21:15 +03:00
|
|
|
func (*DesktopNamePseudoEncoding) Type() EncodingType { return EncDesktopNamePseudo }
|
|
|
|
|
|
|
|
// Read implements the Encoding interface.
|
|
|
|
func (enc *DesktopNamePseudoEncoding) Read(c Conn, rect *Rectangle) error {
|
|
|
|
var length uint32
|
|
|
|
if err := binary.Read(c, binary.BigEndian, &length); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
name := make([]byte, length)
|
|
|
|
if err := binary.Read(c, binary.BigEndian, &name); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
enc.Name = name
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (enc *DesktopNamePseudoEncoding) Write(c Conn, rect *Rectangle) error {
|
|
|
|
if err := binary.Write(c, binary.BigEndian, uint32(len(enc.Name))); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := binary.Write(c, binary.BigEndian, enc.Name); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.Flush()
|
|
|
|
}
|