/// <summary>Initializes the native ManagedSession. Called after Originate completes successfully .</summary>
internal void Initialize()
{
if (allocated == 0)
{
throw new InvalidOperationException("Cannot initialize a ManagedSession until it is allocated (originated successfully).");
}
// P/Invoke generated function pointers stick around until the delegate is collected
// By sticking the delegates in fields, their lifetime won't be less than the session
// So we don't need to worry about GCHandles and all that....
// Info here: http://blogs.msdn.com/cbrumme/archive/2003/05/06/51385.aspx
this._inputCallbackRef = inputCallback;
this._hangupCallbackRef = hangupCallback;
InitManagedSession(ManagedSession.getCPtr(this).Handle, this._inputCallbackRef, this._hangupCallbackRef);
this._variables = new ChannelVariables(this);
}