123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using System.Collections.Generic;
- using WingServerCommon.Log;
- using WingServerCommon.Utilities;
- namespace WingRtmpService.ChannelManagers
- {
- class ChannelConstant
- {
- public const string CreateChannelKey = "CreateChannelKey";
- public const string DeleteChannelKey = "DeleteChannelKey";
- public const string GetChannelListKey = "GetChannelListKey";
- }
- class ChannelParameter
- {
- private readonly Dictionary<string, string> _parameter;
- public ChannelParameter()
- {
- _parameter = new Dictionary<string, string>();
- }
- public Dictionary<string, string> Parameter => _parameter;
- public void SetCreateParameter(string channelName)
- {
- if (!_parameter.ContainsKey(ChannelConstant.CreateChannelKey))
- {
- _parameter.Add(ChannelConstant.CreateChannelKey,
- GetChannelName(channelName));
- }
- else
- {
- _parameter[ChannelConstant.CreateChannelKey] = GetChannelName(channelName);
- }
- }
- public void SetDeleteParameter(string cid)
- {
- if (string.IsNullOrEmpty(cid))
- {
- Logger.WriteLineError("Channel cid is empty.");
- return;
- }
- if (!_parameter.ContainsKey(ChannelConstant.DeleteChannelKey))
- {
- _parameter.Add(ChannelConstant.DeleteChannelKey, cid);
- }
- else
- {
- _parameter[ChannelConstant.DeleteChannelKey] = cid;
- }
- }
- public void SetGetChannelListParameter(int maxRecordsCount)
- {
- if (maxRecordsCount > 0)
- {
- if (!_parameter.ContainsKey(ChannelConstant.GetChannelListKey))
- {
- _parameter.Add(ChannelConstant.GetChannelListKey, maxRecordsCount.ToString());
- }
- else
- {
- _parameter[ChannelConstant.GetChannelListKey] = maxRecordsCount.ToString();
- }
- }
- }
- private static string GetChannelName(string channelName)
- {
- return !string.IsNullOrEmpty(channelName) ? channelName : IdHelper.Generate<string>();
- }
- }
- }
|