public void AttachConnection(Connection connection, ConnectionArgs args) { var adapter = new PlayerIOConnectionAdapter(connection); try { this.SetConnection(adapter, args); this._adapter = adapter; } catch { adapter.Dispose(); throw; } }
public Task <IConnection> ConnectAsync() { if (this._disposed) { throw new ObjectDisposedException(nameof(RPCConnection)); } if (this.Connection?.Connected ?? false) { return(TaskHelper.FromResult(this.Connection)); } return(this.GetConnectionAsync() .Then(t => { this._connection = new PlayerIOConnectionAdapter(t.Result); return this.Connection; }) .ToSafeTask()); }