iamkinetic / NEventSocket

A reactive FreeSwitch eventsocket library for .Net/.Net Framework (.net standard 2)
Mozilla Public License 2.0
26 stars 11 forks source link

Originate should not set UUID automatically. #7

Closed Josbleuet closed 3 years ago

Josbleuet commented 3 years ago

Also quick fix to remove nested '}' when there is no ChannelVariables.

ticpu commented 3 years ago

This change comes due to the fact that NEventSocket never has been able to handle originate spawning multiple channels.

When a group call is created, NEventSocket assigns a UUID using {...} which causes the UUID to be assigned to all the channels created by the originate. This causes CRITICAL messages to appear in the FreeSWITCH output which will rightfully complain about duplicate UUIDs being created. This will cause originate to return as soon as any channel emits an event, as FreeSWITCH will stop the originate because one of the UUID returns a channel termination which causes all the channels to terminate because they're sharing the UUID. This will also happen because NEventSocket will receive a channel event that it is waiting for that will correspond to the first event to arrive from any channel (since they're sharing the UUID too).

The modification that this pull request bring, is to wait for the async event called BACKGROUND_JOB instead of waiting for single channel events. This means that FreeSWITCH will return when all the channels have had a return value, may it be a success or failure. Once any channel succeed, the body of the BACKGROUND_JOB event will return a +OK, if all the channels have failed, it will return a - followed by an error message. This indicates the the async job has been completed by FreeSWITCH and should be the only way to indicate that the originate has completed.