/// <summary> /// Connect to ICE interface on running Murmur server /// </summary> /// <param name="address">murmur server address</param> /// <param name="port">ice port</param> /// <param name="secret">ice password</param> /// <param name="timeout"></param> /// <returns>object of murmur server</returns> public MetaPrx Connect(string address, int port, string secret, string callbackAddress = "127.0.0.1", int callbackPort = 0, int timeout = 1000) { this.timeout = timeout; // initialize run(new string[] { }); ic = Ice.Util.initialize(_data); // set ice secret if (!string.IsNullOrEmpty(secret)) { ic.getImplicitContext().put("secret", secret); } try { var connectionString = string.Format("Meta:tcp -h {0} -p {1} -t {2}", address, port, timeout); // Create a proxy var obj = ic.stringToProxy(connectionString); // Tests whether the target object of this proxy can be reached. obj.ice_ping(); // initialize metadata of murmur server _meta = MetaPrxHelper.uncheckedCast(obj); var portString = (callbackPort > 0) ? string.Format("-p {0}", callbackPort) : ""; var connectionStringCB = string.Format("tcp -h {0} {1} -t {2}", callbackAddress, portString, timeout); // Create the callback adapter ic.getProperties().setProperty("Ice.PrintAdapterReady", "0"); _adapter = ic.createObjectAdapterWithEndpoints("Callback.Client", connectionStringCB); _adapter.activate(); _meta.ice_ping(); } catch (System.Exception e) { Console.WriteLine(e.ToString()); throw new MurmurPlugin.ConnectionRefusedException(); } // FIXME: check for valid ice secret, because getLogLen() is working only if "icesecretwrite" is valid // (there a secure hole - get methods allowed if "icesecretread" is not set) // if secret is invalid it throws UnmarshalOutOfBoundsException(); try { // set allowhtml property to the server to check ice writesecret _meta.getAllServers()[0].setConf("allowhtml", "true"); } catch { throw new MurmurPlugin.InvalidSecretException(); } return(_meta); }
public MurmurSession() { communicator = Util.initialize(); proxy = communicator.stringToProxy("Meta:tcp -h 94.23.170.70 -p 6502"); meta = MetaPrxHelper.uncheckedCast(proxy); server = meta.getAllServers().First(); users = server.getUsers().Values; }
/// <summary> /// Return all servers /// </summary> /// <param name="cache"></param> /// <returns></returns> public SerializableDictionary <int, IVirtualServer> GetAllServers(bool cache = false) { // clear // (it's needed to update one time to cache) if (_isNewAllServers || !cache) { _isNewAllServers = false; // add to cache foreach (var s in _meta.getAllServers()) { var vs = new VirtualServer(s, this); if (!_servers.ContainsKey(vs.Id)) { _servers.Add(vs.Id, vs); } } } return(_servers); }