/// <summary> /// Logs into a specified universe with the given authentication details and bot /// name. Chainable and thread-safe. /// </summary> /// <remarks> /// This function makes an internal call to <see cref="Pump"/>. Due to the same /// limitations, this function cannot be called from within an event handler that /// has been fired by a prior call to Pump. /// /// Servers always add square brackets around a bot's name. /// </remarks> public Instance Login(Uniserver universe, string username, string password, string botname) { lock (Mutex) { if (isPumping) { throw new InvalidOperationException("Cannot login whilst handling a pumped event"); } else { isPumping = true; } try { Functions.Call(() => Functions.vp_connect_universe(Pointer, universe.Host, universe.Port)); Functions.Call(() => Functions.vp_login(Pointer, username, password, botname)); } finally { isPumping = false; } name = botname; return(this); } }
/// <summary> /// Logs into a specified universe with the given authentication details and /// bot name. Chainable. /// </summary> public Instance Login(Uniserver universe, string username, string password, string botname) { int rc; lock (this) rc = Functions.vp_connect_universe(pointer, universe.Host, universe.Port); if (rc != 0) throw new VPException((ReasonCode)rc); lock (this) rc = Functions.vp_login(pointer, username, password, botname); if (rc != 0) throw new VPException((ReasonCode)rc); else return this; }