mirror of
https://github.com/amitbet/vncproxy.git
synced 2025-09-23 10:28:54 +00:00
refactored player code
This commit is contained in:
@@ -193,6 +193,40 @@ func (msg *PointerEvent) Write(c io.Writer) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type ClientFence struct {
|
||||
}
|
||||
|
||||
func (*ClientFence) Type() common.ClientMessageType {
|
||||
return common.ClientFenceMsgType
|
||||
}
|
||||
|
||||
func (cf *ClientFence) Read(c io.Reader) (common.ClientMessage, error) {
|
||||
bytes := make([]byte, 3)
|
||||
c.Read(bytes)
|
||||
if _, err := c.Read(bytes); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var flags uint32
|
||||
if err := binary.Read(c, binary.BigEndian, &flags); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var length uint8
|
||||
if err := binary.Read(c, binary.BigEndian, &length); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bytes = make([]byte, length)
|
||||
if _, err := c.Read(bytes); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cf, nil
|
||||
}
|
||||
|
||||
func (msg *ClientFence) Write(c io.Writer) error {
|
||||
panic("not implemented!")
|
||||
}
|
||||
|
||||
// ClientCutText holds the wire format message, sans the text field.
|
||||
type ClientCutText struct {
|
||||
_ [3]byte // padding
|
||||
|
@@ -12,7 +12,7 @@ import (
|
||||
type ServerConn struct {
|
||||
c io.ReadWriter
|
||||
cfg *ServerConfig
|
||||
|
||||
|
||||
protocol string
|
||||
m sync.Mutex
|
||||
// If the pixel format uses a color map, then this is the color
|
||||
@@ -149,7 +149,7 @@ func (c *ServerConn) SetHeight(h uint16) {
|
||||
}
|
||||
|
||||
func (c *ServerConn) handle() error {
|
||||
|
||||
|
||||
defer func() {
|
||||
c.Listeners.Consume(&common.RfbSegment{
|
||||
SegmentType: common.SegmentConnectionClosed,
|
||||
@@ -197,7 +197,11 @@ func (c *ServerConn) handle() error {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Debugf("ServerConn.Handle got ClientMessage: %s, %v", parsedMsg.Type(), parsedMsg)
|
||||
logger.Infof("ServerConn.Handle got ClientMessage: %s, %v", parsedMsg.Type(), parsedMsg)
|
||||
//TODO: treat set encodings by allowing only supported encoding in proxy configurations
|
||||
//// if parsedMsg.Type() == common.SetEncodingsMsgType{
|
||||
//// c.cfg.Encodings
|
||||
//// }
|
||||
|
||||
seg := &common.RfbSegment{
|
||||
SegmentType: common.SegmentFullyParsedClientMessage,
|
||||
|
@@ -88,6 +88,14 @@ func attachNewServerConn(c io.ReadWriter, cfg *ServerConfig, sessionId string) e
|
||||
return err
|
||||
}
|
||||
|
||||
//run the handler for this new incoming connection from a vnc-client
|
||||
//this is done before the init sequence to allow listening to server-init messages (and maybe even interception in the future)
|
||||
err = cfg.NewConnHandler(cfg, conn)
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
return err
|
||||
}
|
||||
|
||||
if err := ServerClientInitHandler(cfg, conn); err != nil {
|
||||
conn.Close()
|
||||
return err
|
||||
@@ -102,7 +110,6 @@ func attachNewServerConn(c io.ReadWriter, cfg *ServerConfig, sessionId string) e
|
||||
if cfg.UseDummySession {
|
||||
conn.SessionId = "dummySession"
|
||||
}
|
||||
cfg.NewConnHandler(cfg, conn)
|
||||
|
||||
//go here will kill ws connections
|
||||
conn.handle()
|
||||
|
Reference in New Issue
Block a user