From a89c17a564b9a9a9bbee261d3b4a158c4efff36d Mon Sep 17 00:00:00 2001 From: Edmundo Gonzalez <51725820+edgonmsft@users.noreply.github.com> Date: Thu, 26 Aug 2021 22:34:56 +0000 Subject: [PATCH] Adding sshRPC interface --- sshRpc.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 sshRpc.go diff --git a/sshRpc.go b/sshRpc.go new file mode 100644 index 000000000..78ac90f82 --- /dev/null +++ b/sshRpc.go @@ -0,0 +1,34 @@ +package liveshare + +import ( + "context" + "errors" +) + +type SshRpc struct { + client *Client +} + +func NewSSHRpc(client *Client) (*SshRpc, error) { + if !client.hasJoined() { + return nil, errors.New("client must join before creating server") + } + return &SshRpc{client: client}, nil +} + +type SshServerStartResult struct { + Result bool `json:"result"` + ServerPort string `json:"serverPort"` + User string `json:"user"` + Message string `json:"message"` +} + +func (s *SshRpc) StartRemoteServer(ctx context.Context) (SshServerStartResult, error) { + var response SshServerStartResult + + if err := s.client.rpc.do(ctx, "ISshServerHostService.startRemoteServer", []string{}, &response); err != nil { + return response, err + } + + return response, nil +}