提交 f22a237b authored 作者: Michael Giagnocavo's avatar Michael Giagnocavo

Start adding some strongly-typed accessors to common channel vars

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@14774 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 2a3be1dc
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AssemblyInfo.cs" /> <Compile Include="AssemblyInfo.cs" />
<Compile Include="ChannelVariables.cs" />
<Compile Include="ManagedSession.cs" /> <Compile Include="ManagedSession.cs" />
<Compile Include="Loader.cs" /> <Compile Include="Loader.cs" />
<Compile Include="Extensions.cs" /> <Compile Include="Extensions.cs" />
......
...@@ -52,6 +52,9 @@ namespace FreeSWITCH.Native ...@@ -52,6 +52,9 @@ namespace FreeSWITCH.Native
/// <summary>Initializes the native ManagedSession. Must be called after Originate.</summary> /// <summary>Initializes the native ManagedSession. Must be called after Originate.</summary>
public void Initialize() public void Initialize()
{ {
if (allocated == 0) {
Log.WriteLine(LogLevel.Critical, "Cannot initialize a ManagedSession until it is allocated (originated successfully).");
}
// P/Invoke generated function pointers stick around until the delegate is collected // 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 // 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.... // So we don't need to worry about GCHandles and all that....
...@@ -59,6 +62,7 @@ namespace FreeSWITCH.Native ...@@ -59,6 +62,7 @@ namespace FreeSWITCH.Native
this._inputCallbackRef = inputCallback; this._inputCallbackRef = inputCallback;
this._hangupCallbackRef = hangupCallback; this._hangupCallbackRef = hangupCallback;
InitManagedSession(ManagedSession.getCPtr(this).Handle, this._inputCallbackRef, this._hangupCallbackRef); InitManagedSession(ManagedSession.getCPtr(this).Handle, this._inputCallbackRef, this._hangupCallbackRef);
this._variables = new ChannelVariables(this);
} }
DtmfCallback _inputCallbackRef; DtmfCallback _inputCallbackRef;
CdeclAction _hangupCallbackRef; CdeclAction _hangupCallbackRef;
...@@ -122,15 +126,9 @@ namespace FreeSWITCH.Native ...@@ -122,15 +126,9 @@ namespace FreeSWITCH.Native
get { return this.Ready(); } get { return this.Ready(); }
} }
Guid _uuid;
bool _uuidSet;
public Guid Uuid { public Guid Uuid {
get { get {
if (!_uuidSet) { return new Guid(this.GetUuid());
_uuid = new Guid(this.GetUuid());
_uuidSet = true;
}
return _uuid;
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论