Open tabdulradi opened 12 years ago
Am I doing it wrong? Is there any better way to connect to multiple servers in the same page? I am thinking to use IFrames instead, to solve my problem.
Calling GateOne.init() twice on the same page isn't supported... Yet. The problem is that GateOne stores all of the terminals' settings in GateOne.terminals[termNum]. If you call GateOne.init() and open a terminal it will store that terminal's information in GateOne.terminals[1]. then you call GateOne.init() again and it will overwrite GateOne.terminals[1].
Also, the WebSocket is stored in GateOne.ws. When you open up that second connection it will overwrite GateOne.ws, leaving the old WebSocket in a sort of limbo state.
In the short term I may be able to work around this problem by using the prefix like so: GateOne.terminals[GateOne.prefs.prefix+termNum] but that's really not the best way to do it (it should work though). I'll play around with that and see if I can get it working without having to make too many changes. If it doesn't "just work" after a little bit of search/replace it will have to wait until the next version.
For reference, nearly all other aspects of Gate One should be OK with multiple instances like that but you need to make sure you call GateOne.init() with a different prefix for each div you're attaching it to.
For the next version of Gate One I will be looking at changing how Gate One is initialized to be more like other JavaScript libraries. Probably something like "Go1 = new GateOne(
I should also mention that Gate One will soon be supporting multiple terminal "types" that run different commands on the server. So you could call newTerminal(termNum, type) and depending on that type value it would launch either the 'command' in server.conf or something different (still haven't worked out how I want to configure it... Probably just a 'commands = {'default': 'ssh_connect.py ...', 'ipython': 'ipython', ...} option).
In the mean time you can work around this issue by having a single Gate One instance that controls multiple terminals simultaneously... You just need to configure Gate One to run a command-line program that allows one to select the terminal type to bring up. So you call newTerminal() and then just send it a string like: GateOne.Input.sendString('ipython\n');
OK, I've done some investigating and I believe I've determined most of what needs to change in order to support multiple instances of GateOne on the same page. It is too much to change for 1.1. However, it will be one of the first things I change after 1.1 is released.
It's not that it will be complicated it is just that it is too much to change so close to the release of 1.1. There's too many bugs that could be introduced.
I'm going to label this issue as a feature request and leave it in the queue until I can get GateOne working as intended.
I was thinking about this today and came up with an easier/alternate workaround: Just include two copies of gateone.js on the same page. Just do a search/replace "GateOne" with "Gate2" or something like that on one of the copies. Then just call Gate2.init() on the second copy.
Sure, it isn't efficient but it'll work until I get instantiation working which should be shortly after 1.1.
I want to put multiple Gateone terminals in the same page, but each of them is pointing to a different server. So I did the following test:
Then I put this html instead of /templates/index.html, in the first server, and opened it. It seems to work at first, but then I got some warnings about shortcuts
Finally I get this message about accepting SSL http://imgur.com/bwXDZ for a fraction of a second then the page go back one level in history!