SafeDispatch/SipComponent/Simoco/SimocoSipMessageGenerator.cs
2024-02-22 18:43:59 +02:00

41 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Independentsoft.Sip.Methods;
using Independentsoft.Sip;
namespace SipComponent.Simoco
{
/// <summary>
/// Class that generates Sip messages used for Simoco
/// </summary>
internal class SimocoSipMessageGenerator : SipMessageGenerator
{
/// <summary>
/// Generates a Sip message using the specified parameters
/// </summary>
/// <param name="destinationID"></param>
/// <param name="senderID"></param>
/// <param name="sipServer"></param>
/// <param name="sipServerPort"></param>
/// <param name="text"></param>
/// <returns></returns>
public override Message Generate(string destinationID, string senderID, string sipServer, int sipServerPort, string text, bool groupSms = false)
{
Message sipMessage = base.Generate(destinationID, senderID, sipServer, sipServerPort, text);
sipMessage.ContentType = "application/octet-stream";
// Softul de pe AIS are nevoie de punct si virgula (;) dupa short-data
sipMessage.Header.Add("Ais-Service", "short-data;");
sipMessage.Header.Add("Ais-Options", "service-attributes; coding=unicode-16");
sipMessage.Header.Add("Content-Transfer-Encoding", "base64");
sipMessage.Body = Convert.ToBase64String(Encoding.BigEndianUnicode.GetBytes(text));
return sipMessage;
}
}
}