How to keep a connection?


#1

how to keep this connection , when clicked the li element, i want to use this connection everywhere
how to define a global variable?

@li.on 'click','li', ->
    SSH = new SSH_Connection()
    console.log SSH

#2

Perhaps you should elaborate and tell us what exactly you’re trying to achieve with this?


#3

I’m writing a package, like xshell or SecureCRT, switch the servers

  <li host='192.168.1.1' password='111'  username='hello'>192.168.1.1</li>
  <li host='192.168.1.2' password='111'  username='hello'>192.168.1.2</li>

when clicked the li ele:

@li.on 'click','li', ->
    host = this.host
    password = this.password
    username = this.username
    SSH = new SSH_Connection(host,username,password)
    # here:  SSH connection can not use in the atom window , i want to define a global variable when the window loaded, use this connection at anytime anywhere , until i close the window or click another server  
    # when clicked the server ip, i want to use it in pane or menu , treeview to connect 
    #does not need to establish a new connection
    #I tried several ways,does not work