internal virtual void OnBegin(ushort remoteChannel, Begin begin)
{
lock (this.ThisLock)
{
if (remoteChannel > this.channelMax)
{
throw new AmqpException(ErrorCode.NotAllowed,
Fx.Format(SRAmqp.AmqpHandleExceeded, this.channelMax + 1));
}
Session session = this.GetSession(this.localSessions, begin.RemoteChannel);
session.OnBegin(remoteChannel, begin);
int count = this.remoteSessions.Length;
if (count - 1 < remoteChannel)
{
int size = Math.Min(count * 2, this.channelMax + 1);
Session[] expanded = new Session[size];
Array.Copy(this.remoteSessions, expanded, count);
this.remoteSessions = expanded;
}
var remoteSession = this.remoteSessions[remoteChannel];
if (remoteSession != null)
{
throw new AmqpException(ErrorCode.HandleInUse,
Fx.Format(SRAmqp.AmqpHandleInUse, remoteChannel, remoteSession.GetType().Name));
}
this.remoteSessions[remoteChannel] = session;
}
}