fix default message handler

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-06-29 16:42:54 +03:00
parent e1d11c19bb
commit b5a9437686
2 changed files with 38 additions and 2 deletions

View File

@ -254,6 +254,35 @@ func (*DefaultClientMessageHandler) Handle(c Conn) error {
serverMessages[m.Type()] = m serverMessages[m.Type()] = m
} }
spf := &SetPixelFormat{PF: *cfg.PixelFormat}
if err = spf.Write(c); err != nil {
// cfg.ErrorCh <- err
return err
}
senc := &SetEncodings{
EncNum: uint16(len(cfg.Encodings)),
Encodings: make([]EncodingType, 0, len(cfg.Encodings)),
}
for _, enc := range cfg.Encodings {
senc.Encodings = append(senc.Encodings, enc.Type())
}
if err = senc.Write(c); err != nil {
return err
}
fbur := &FramebufferUpdateRequest{
Inc: 0,
X: 0,
Y: 0,
Width: c.Width(),
Height: c.Height(),
}
if err = fbur.Write(c); err != nil {
return err
}
go func() { go func() {
defer wg.Done() defer wg.Done()
for { for {
@ -279,7 +308,7 @@ func (*DefaultClientMessageHandler) Handle(c Conn) error {
} }
msg, ok := serverMessages[messageType] msg, ok := serverMessages[messageType]
if !ok { if !ok {
err = fmt.Errorf("unknown message-type: %v", messageType) err = fmt.Errorf("unknown message-type: %#+v", messageType)
cfg.ErrorCh <- err cfg.ErrorCh <- err
return return
} }

View File

@ -257,7 +257,9 @@ type DefaultClientServerInitHandler struct{}
// Handle provide default server init handler // Handle provide default server init handler
func (*DefaultClientServerInitHandler) Handle(c Conn) error { func (*DefaultClientServerInitHandler) Handle(c Conn) error {
var err error var err error
srvInit := ServerInit{} srvInit := ServerInit{}
pf := PixelFormat{}
if err = binary.Read(c, binary.BigEndian, &srvInit.FBWidth); err != nil { if err = binary.Read(c, binary.BigEndian, &srvInit.FBWidth); err != nil {
return err return err
@ -265,9 +267,11 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error {
if err = binary.Read(c, binary.BigEndian, &srvInit.FBHeight); err != nil { if err = binary.Read(c, binary.BigEndian, &srvInit.FBHeight); err != nil {
return err return err
} }
if err = binary.Read(c, binary.BigEndian, &srvInit.PixelFormat); err != nil { if err = binary.Read(c, binary.BigEndian, &pf); err != nil {
return err return err
} }
srvInit.PixelFormat = &pf
if err = binary.Read(c, binary.BigEndian, &srvInit.NameLength); err != nil { if err = binary.Read(c, binary.BigEndian, &srvInit.NameLength); err != nil {
return err return err
} }
@ -276,7 +280,9 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error {
if err = binary.Read(c, binary.BigEndian, &srvInit.NameText); err != nil { if err = binary.Read(c, binary.BigEndian, &srvInit.NameText); err != nil {
return err return err
} }
c.SetDesktopName(srvInit.NameText) c.SetDesktopName(srvInit.NameText)
if c.Protocol() == "aten1" { if c.Protocol() == "aten1" {
c.SetWidth(800) c.SetWidth(800)
c.SetHeight(600) c.SetHeight(600)
@ -286,6 +292,7 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error {
c.SetHeight(srvInit.FBHeight) c.SetHeight(srvInit.FBHeight)
c.SetPixelFormat(srvInit.PixelFormat) c.SetPixelFormat(srvInit.PixelFormat)
} }
if c.Protocol() == "aten1" { if c.Protocol() == "aten1" {
ikvm := struct { ikvm := struct {
_ [8]byte _ [8]byte