diff --git a/client.go b/client.go index 852577b..397422e 100644 --- a/client.go +++ b/client.go @@ -244,10 +244,6 @@ func (*DefaultClientMessageHandler) Handle(c Conn) error { return nil } -type ClientHandler interface { - Handle(Conn) error -} - // A ClientConfig structure is used to configure a ClientConn. After // one has been passed to initialize a connection, it must not be modified. type ClientConfig struct { diff --git a/handlers.go b/handlers.go index 1ed7ae2..bec88d5 100644 --- a/handlers.go +++ b/handlers.go @@ -5,6 +5,10 @@ import ( "fmt" ) +type ClientHandler interface { + Handle(Conn) error +} + // ClientMessage is the interface type ClientMessage interface { String() string @@ -13,6 +17,10 @@ type ClientMessage interface { Write(Conn) error } +type ServerHandler interface { + Handle(Conn) error +} + // ServerMessage is the interface type ServerMessage interface { String() string @@ -199,7 +207,7 @@ func (*DefaultServerSecurityHandler) Handle(c Conn) error { sType, ok := secTypes[secType] if !ok { - return fmt.Errorf("server type %d not implemented") + return fmt.Errorf("security type %d not implemented", secType) } var authCode uint32 @@ -251,14 +259,15 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error { return err } c.SetDesktopName(srvInit.NameText) - c.SetWidth(srvInit.FBWidth) - c.SetHeight(srvInit.FBHeight) if c.Protocol() == "aten" { + c.SetWidth(800) + c.SetHeight(600) c.SetPixelFormat(NewPixelFormatAten()) } else { + c.SetWidth(srvInit.FBWidth) + c.SetHeight(srvInit.FBHeight) c.SetPixelFormat(srvInit.PixelFormat) } - if c.Protocol() == "aten" { ikvm := struct { _ [8]byte @@ -280,14 +289,15 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error { return err } - caps.ServerMessagesNum = uint16(16) + caps.ServerMessagesNum = uint16(2) var item [16]byte for i := uint16(0); i < caps.ServerMessagesNum; i++ { if err := binary.Read(c, binary.BigEndian, &item); err != nil { return err } - fmt.Printf("server message cap %v\n", item) + fmt.Printf("server message cap %s\n", item) } + /* for i := uint16(0); i < caps.ClientMessagesNum; i++ { if err := binary.Read(c, binary.BigEndian, &item); err != nil { @@ -302,10 +312,10 @@ func (*DefaultClientServerInitHandler) Handle(c Conn) error { fmt.Printf("encoding cap %s\n", item) } */ - var pad [1]byte - if err := binary.Read(c, binary.BigEndian, &pad); err != nil { - return err - } + // var pad [1]byte + // if err := binary.Read(c, binary.BigEndian, &pad); err != nil { + // return err + // } } return nil } diff --git a/server.go b/server.go index 014d683..f360f26 100644 --- a/server.go +++ b/server.go @@ -135,10 +135,6 @@ type ServerConn struct { quit chan struct{} } -type ServerHandler interface { - Handle(Conn) error -} - var ( DefaultServerHandlers []ServerHandler = []ServerHandler{ &DefaultServerVersionHandler{},