-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Azure Communication Services][CallAutomation]Create Customcontext cl…
…ass (#37548) * create Customcontext class * fix UT * update api * for groupcall, create both headers by default * fix comments * update api
- Loading branch information
1 parent
29c31fe
commit df84a93
Showing
12 changed files
with
229 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
sdk/communication/Azure.Communication.CallAutomation/src/Models/CustomContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Azure.Communication.CallAutomation | ||
{ | ||
/// <summary> | ||
/// CustomContext details. | ||
/// </summary> | ||
public class CustomContext | ||
{ | ||
/// <summary> Dictionary of VOIP headers. </summary> | ||
public IDictionary<string, string> VoipHeaders { get; } | ||
|
||
/// <summary> Dictionary of SIP headers. </summary> | ||
public IDictionary<string, string> SipHeaders { get; } | ||
|
||
/// <summary> | ||
/// Creates a new CustomContext. | ||
/// </summary> | ||
internal CustomContext(IDictionary<string, string> sipHeaders, IDictionary<string, string> voipHeaders) | ||
{ | ||
SipHeaders = sipHeaders; | ||
VoipHeaders = voipHeaders; | ||
} | ||
|
||
/// <summary> | ||
/// Add a custom context sip or voip header. | ||
/// </summary> | ||
/// <param name="header">custom context sip UUI, custom header or voip header.</param> | ||
public void Add(CustomContextHeader header) | ||
{ | ||
if (header is SIPUUIHeader sipUUIHeader) | ||
{ | ||
if (SipHeaders == null) | ||
{ | ||
throw new InvalidOperationException("Cannot add sip header, SipHeaders is null."); | ||
} | ||
SipHeaders.Add(sipUUIHeader.Key, sipUUIHeader.Value); | ||
} | ||
else if (header is SIPCustomHeader sipCustomHeader) | ||
{ | ||
if (SipHeaders == null) | ||
{ | ||
throw new InvalidOperationException("Cannot add sip header, SipHeaders is null."); | ||
} | ||
SipHeaders.Add(sipCustomHeader.Key, sipCustomHeader.Value); | ||
} | ||
else if (header is VoipHeader voipHeader) | ||
{ | ||
if (VoipHeaders == null) | ||
{ | ||
throw new InvalidOperationException("Cannot add voip header, VoipHeaders is null"); | ||
} | ||
VoipHeaders.Add(voipHeader.Key, voipHeader.Value); | ||
} | ||
else | ||
{ | ||
throw new InvalidOperationException("Unknown custom context header type."); | ||
} | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
sdk/communication/Azure.Communication.CallAutomation/src/Models/CustomContextHeader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace Azure.Communication.CallAutomation | ||
{ | ||
/// <summary> | ||
/// The base class of CustomContext SipHeader and VoipHeader. | ||
/// </summary> | ||
public abstract class CustomContextHeader | ||
{ | ||
/// <summary> | ||
/// The CustomContext Key name. | ||
/// </summary> | ||
public string Key { get; } | ||
|
||
/// <summary> | ||
/// The CustomContext Key value. | ||
/// </summary> | ||
public string Value { get; } | ||
|
||
/// <summary> | ||
/// Creates a new CustomContextHeader | ||
/// </summary> | ||
protected CustomContextHeader(string key, string value) | ||
{ | ||
Key = key; | ||
Value = value; | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
sdk/communication/Azure.Communication.CallAutomation/src/Models/SIPCustomHeader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace Azure.Communication.CallAutomation | ||
{ | ||
/// <summary> | ||
/// Custom Context Sip header. | ||
/// </summary> | ||
public class SIPCustomHeader : CustomContextHeader | ||
{ | ||
/// <summary> | ||
/// Create a new Sip header. | ||
/// </summary> | ||
/// <param name="key">sip header key name.</param> | ||
/// <param name="value">sip header value.</param> | ||
public SIPCustomHeader(string key, string value) : base("X-MS-Custom-"+key, value) | ||
{ | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
sdk/communication/Azure.Communication.CallAutomation/src/Models/SIPUUIHeader.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
namespace Azure.Communication.CallAutomation | ||
{ | ||
/// <summary> | ||
/// Custom Context User-to-User Sip header. | ||
/// </summary> | ||
public class SIPUUIHeader : CustomContextHeader | ||
{ | ||
/// <summary> | ||
/// Create a new Sip UUI header. | ||
/// </summary> | ||
/// <param name="value">CustomContext Sip UUI value.</param> | ||
public SIPUUIHeader(string value) : base("User-to-User", value) | ||
{ | ||
} | ||
} | ||
} |
Oops, something went wrong.