private TurnMessage ProcessSetActiveDestinationRequest(Allocation allocation, TurnMessage request, IPEndPoint reflexEndPoint)
{
if (allocation == null)
throw new TurnServerException(ErrorCode.NoBinding);
if (request.DestinationAddress == null)
throw new TurnServerException(ErrorCode.BadRequest);
allocation.ActiveDestination = request.DestinationAddress.IpEndPoint;
allocation.Permissions.Permit(request.DestinationAddress.IpEndPoint);
logger.WriteInformation(string.Format("Set Active Destination: {2} --> {0} <--> {1}", allocation.Alocated.ToString(), allocation.Reflexive.ToString(), allocation.ActiveDestination.ToString()));
uint sequenceNumber = (request.MsSequenceNumber != null) ? request.MsSequenceNumber.SequenceNumber : 0;
return new TurnMessage()
{
IsAttributePaddingDisabled = true,
MessageType = MessageType.SetActiveDestinationResponse,
TransactionId = request.TransactionId,
MagicCookie = new MagicCookie(),
Realm = new Realm(TurnMessageRfc.MsTurn)
{
Ignore = true,
Value = Authentificater.Realm,
},
MsUsername = new MsUsername()
{
Ignore = true,
Value = request.MsUsername.Value,
},
//MsUsername = allocation.Username,
MessageIntegrity = new MessageIntegrity(),
MsSequenceNumber = new MsSequenceNumber()
{
ConnectionId = allocation.ConnectionId,
SequenceNumber = sequenceNumber,//allocation.SequenceNumber,
},
};
}