You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@guacamole.apache.org by messido <mo...@gmail.com> on 2017/09/15 20:47:56 UTC

Guacamole only shows a screenshot when using importState

To cut it short, I'm using my own front end. One of my pages create the
connection with guacamole, and when connection is established it uses
"exportState" to save the state inside localStorage as a JSON string..
So far so good, I get valid data.

Now when I go to a different page and importState from local storage (after
JSON parsing) I get almost like a snapshot of the host machine, I can see it
but cant interact with anything.. pretty sure it's just a still image
because the terminal cursor isn't flashing.. anyways here's my code 

@ViewChild('display') display: ElementRef;
   guac: any  = new Guacamole.Client(new Guacamole.HTTPTunnel('tunnel'));

    constructor(....) {};

    ngAfterContentInit() {
       
this.display.nativeElement.appendChild(this.guac.getDisplay().getElement());
        this.guac.importState(JSON.parse(localStorage.getItem('guacState')),
() => {
            console.log('done importing state');
        });
        // Mouse
        const mouse = new
Guacamole.Mouse(this.guac.getDisplay().getElement());

        mouse.onmousedown =
            mouse.onmouseup   =
                mouse.onmousemove = (mouseState) => {
                    this.guac.sendMouseState(mouseState);
                };

        // Keyboard
        const keyboard = new Guacamole.Keyboard(document);

        keyboard.onkeydown = (keysym) => {
            this.guac.sendKeyEvent(1, keysym);
        };

        keyboard.onkeyup = (keysym) => {
            this.guac.sendKeyEvent(0, keysym);

        };
        this.guac.onerror = error => {
          alert(error);
        };
    }

Am I using the wrong functionality? Are importState and exportState meant to
be like just a snapshot of that current moment? I'm looking for a way  to
save the clients.. state... so i can move it around and start that same
session from different computers




--
Sent from: http://apache-guacamole-incubating-users.2363388.n4.nabble.com/

Re: Guacamole only shows a screenshot when using importState

Posted by Mike Jumper <mi...@guac-dev.org>.
On Fri, Sep 15, 2017 at 7:32 PM, messido <mo...@gmail.com> wrote:

> Appreciate your very quick response! I just have a quick follow up question
> if you have the chance..
>
> Since I have the connectionID string inside my Java class, how can I send
> it
> to my frontend angular app, or in other words, back to my
> guacamole-common-js obj? Can it be done within guacamole or am I going to
> need an external module to transmit the ID?
>
>
No, the Guacamole API is pretty strict with respect to scope and separation
of concerns. Exposing the connection ID, if at all, would be an
implementation detail of the Guacamole-driven application. If possible, I
would recommend instead keeping that ID purely server-side, generating your
own opaque IDs for exposure on the client-side as you see fit. That way,
you will have full control of who can connect to what, and the flow of
information surrounding the creation of each connection.

- Mike

Re: Guacamole only shows a screenshot when using importState

Posted by messido <mo...@gmail.com>.
Appreciate your very quick response! I just have a quick follow up question
if you have the chance..

Since I have the connectionID string inside my Java class, how can I send it
to my frontend angular app, or in other words, back to my
guacamole-common-js obj? Can it be done within guacamole or am I going to
need an external module to transmit the ID?



--
Sent from: http://apache-guacamole-incubating-users.2363388.n4.nabble.com/

Re: Guacamole only shows a screenshot when using importState

Posted by Mike Jumper <mi...@guac-dev.org>.
On Fri, Sep 15, 2017 at 1:47 PM, messido <mo...@gmail.com> wrote:

> To cut it short, I'm using my own front end. One of my pages create the
> connection with guacamole, and when connection is established it uses
> "exportState" to save the state inside localStorage as a JSON string..
> So far so good, I get valid data.
>
> Now when I go to a different page and importState from local storage (after
> JSON parsing) I get almost like a snapshot of the host machine, I can see
> it
> but cant interact with anything.. pretty sure it's just a still image
> because the terminal cursor isn't flashing.. anyways here's my code
>
> ...
>
> Am I using the wrong functionality? Are importState and exportState meant
> to
> be like just a snapshot of that current moment? I'm looking for a way  to
> save the clients.. state... so i can move it around and start that same
> session from different computers
>
>
Yes and yes. ;)

importState() and exportState() deal with the instantaneous internal state
of a particular Guacamole.Client instance. They do not deal with the
continuous, ever-changing state of an active connection. For that, you need
to leverage the screen replication features built into the backend,
normally referred to as "screen sharing".

When a connection is created, guacd automatically allocates a unique
identifier for that connection, sending that identifier back during the
initial Guacamole protocol handshake:

http://guacamole.incubator.apache.org/doc/gug/guacamole-protocol.html#guacamole-protocol-handshake

This identifier can be automatically parsed and retrieved using
getConnectionID() of ConfiguredGuacamoleSocket:

http://guacamole.incubator.apache.org/doc/guacamole-common/org/apache/guacamole/protocol/ConfiguredGuacamoleSocket.html#getConnectionID--

For users which should see the same screen, you establish connections to
the same guacd exactly as for any other connection, except you pass in the
connection ID instead of a protocol using setConnectionID():

http://guacamole.incubator.apache.org/doc/guacamole-common/org/apache/guacamole/protocol/GuacamoleConfiguration.html#setConnectionID-java.lang.String-

guacd will join the new connection to the existing connection,
automatically synchronizing state to the new client, and then replicating
incremental state changes across all users sharing that connection.

- Mike