Permalink
Browse files

Updated to support multiple shotgun servers.

  • Loading branch information...
1 parent 475070c commit 4ec111fc74ae8240917ee32a4e75f92c0c09e49a @robblau committed Feb 21, 2012
Showing with 49 additions and 10 deletions.
  1. +18 −3 shotgun_mode.mu
  2. +31 −7 shotgun_state.mu
View
@@ -1068,15 +1068,30 @@ class: ShotgunMinorMode : MinorMode
}
}
- method: sessionFromVersionIDs (void; int[] ids, bool doCompare = false, bool clearFirst = true)
+ method: sessionFromVersionIDs (void; int[] ids, bool doCompare = false, bool clearFirst = true, string flags="")
{
- deb ("shotgun mode sessionFromVersionIDs called\n");
+ deb ("shotgun mode sessionFromVersionIDs(%s, %s, %s, %s) called\n" % (ids, doCompare, clearFirst, flags));
+ StringMap flagMap = StringMap(7);
+ for_each (flag; flags.split(" "))
+ {
+ string[] pair = flag.split("=");
+ flagMap.add(pair[0], pair[1]);
+ }
+ deb ("flagMap: %s\n" % flagMap.toString());
+
State state = data();
if (0 == sources().size()) state.emptySessionStr = "Loading From Shotgun ...";
if (0 == ids.size()) return;
- _shotgunState.collectVersionInfo(ids, sessionFromInfos(doCompare,clearFirst,));
+ string serverUrl = "";
+ try
+ {
+ serverUrl = "http://%s" % flagMap.find("serverUrl");
+ }
+ catch (...) {;}
+
+ _shotgunState.collectVersionInfo(ids, sessionFromInfos(doCompare,clearFirst,), serverUrl);
}
method: goToPage (void; string url)
View
@@ -89,7 +89,8 @@ class: ShotgunState
ok = false;
}
- if (ok) this.connectToServer();
+ // defer connecting to server until we know which server launched us
+ // if (ok) this.connectToServer();
}
method: recordsReturnedLast(int;)
@@ -162,12 +163,27 @@ class: ShotgunState
}
- method: connectToServer(void; )
+ method: connectToServer(void; string serverUrl="")
{
try
{
- let (url, scriptKey) = lookupServer (_serverURL);
+ string lookup;
+ if (serverUrl == "")
+ {
+ // if we've already connected, then there is nothing to do
+ if (_shotgunServer neq nil) return;
+ lookup = _serverURL;
+ }
+ else
+ lookup = serverUrl;
+ let (url, scriptKey) = lookupServer (lookup);
+
+ /*
+ * default url to connect to becomes last server passed in.
+ * this doesn't work great for sessions where entities come from different
+ * servers, but support for that is in the future
+ */
_serverURL = url;
_scriptKey = scriptKey;
if (url eq nil) throw exception ("ShotgunState: cannot connect to nil url");
@@ -406,7 +422,7 @@ class: ShotgunState
else
{
deb (" nextEntity is %s, requesting info\n" % nextEntity);
- _requestInfo (newTargetIDs, nextEntity, requestedEntities, infos, afterFunc);
+ _requestInfo (newTargetIDs, nextEntity, requestedEntities, infos, afterFunc, "");
}
}
catch (exception exc)
@@ -496,11 +512,18 @@ class: ShotgunState
string targetEntity,
string[] requestedEntities,
StringMap[] infos,
- (void; StringMap[]) afterFunc)
+ (void; StringMap[]) afterFunc,
+ string serverUrl)
{
deb ("ShotgunState _requestInfo called\n");
deb (" targetIDs %s\n" % targetIDs);
deb (" targetEntity %s\n" % targetEntity);
+ deb (" serverUrl %s\n" % serverUrl);
+ deb (" _serverURL %s\n" % _serverURL);
+
+ // if we are trying to talk to a different shotgun server than the default
+ if (serverUrl != _serverURL)
+ connectToServer(serverUrl);
_updateEmptySessionStr (targetEntity);
@@ -535,17 +558,18 @@ class: ShotgunState
]));
}
- method: collectVersionInfo (void; int[] ids, (void; StringMap[]) afterFunc)
+ method: collectVersionInfo (void; int[] ids, (void; StringMap[]) afterFunc, string serverURL="")
{
deb ("ShotgunState collectVersionInfo called\n");
deb (" ids %s\n" % ids);
+ deb (" serverURL %s\n" % serverURL);
if (0 == ids.size()) return;
StringMap[] infos;
for_each (id; ids) infos.push_back(shotgun_fields.freshInfo());
deb (" info[0] %s\n" % infos[0].toString(" "));
- _requestInfo (ids, "Version", string[](), infos, afterFunc);
+ _requestInfo (ids, "Version", string[](), infos, afterFunc, serverURL);
}
method: collectAllVersionInfo (void; (void; StringMap[]) afterFunc)

0 comments on commit 4ec111f

Please sign in to comment.