public static MPProtectedChannel GetChannel(string channelName, int waitTime) { if (MPChannelSettings.Find(channelName) == null) { return(null); } if (waitTime <= 0) { waitTime = 20 * 1000; } ManualTimer timer = new ManualTimer(waitTime); MPProtectedChannel pc = GetChannel(channelName, true); while (!timer.Timeout) { if (pc != null) { return(pc); } pc = GetChannel(channelName, false); System.Threading.Thread.Sleep(200); } MPChannels.Log(string.Format("Cannot open channel to {0}", channelName)); return(null); }
static void _cycleChannelsUp(object o) { ICollection collect = MPChannelSettings.GetChannelList(); while (true) { foreach (object ch in collect) { MPChannelSettings cs = ch as MPChannelSettings; if (cs == null) { cs.Available = false; continue; } string answer = SendAndWaitString(cs.Name, "Echo", "echoPattern", 10 * 1000); if (answer == "echoPattern") { cs.Available = true; } else { cs.Available = false; } } System.Threading.Thread.Sleep(10 * 1000); } }
MPProtectedChannel(MPChannelSettings settings) { this.settings = settings; marker = newMarker; Id = marker.ToString() + ":" + Name; state = State.Connecting; //MPChannels.Log(string.Format("*** Channel {0} created", Id)); System.Threading.ThreadPool.QueueUserWorkItem(_cycle, null); }
public static MPProtectedChannel CreateChannel(string channelName) { MPChannelSettings settings = MPChannelSettings.Find(channelName); if (settings == null) { return(null); } return(new MPProtectedChannel(settings)); }
public static bool IsAvailable(string channelName) { MPChannelSettings cs = MPChannelSettings.Find(channelName); if (cs == null) { return(false); } return(cs.Available); }
//------------------------------------------------------------- static MPChannelSettings BuildItem(string settings) { string[] sa = settings.Split(';'); if (sa.Length < 4) { return(null); } MPChannelSettings user = new MPChannelSettings(); user.array = sa; return(user); }
public static void Init(string[] channelsDescription) { _ChannelsDescription = channelsDescription; foreach (string s in GetChannelsDescription()) { MPChannelSettings settings = BuildItem(s); if (settings != null) { list[settings.Name] = settings; } } }
public static void Init(string[] channelsDescription) { MPChannelSettings.Init(channelsDescription); MPChannelsPool.Start(); System.Threading.ThreadPool.QueueUserWorkItem(_cycleChannelsUp); }