コード例 #1
0
ファイル: ConnectionManager.cs プロジェクト: Yonom/BotBits
        public void AttachConnection(Connection connection, ConnectionArgs args)
        {
            var adapter = new PlayerIOConnectionAdapter(connection);

            try
            {
                this.SetConnection(adapter, args);
                this._adapter = adapter;
            }
            catch
            {
                adapter.Dispose();
                throw;
            }
        }
コード例 #2
0
ファイル: RPCConnection.cs プロジェクト: jkloop45/BotBits
        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());
        }