/// <summary> /// Initialize BaseAppInsightsSessionChannel and calculate used transport. /// Calculate used transport by asking concrete implementation if specific transport is used. /// In case specific transport is not used transportUsed just channel id. /// In case specific transport is used (as for combined channel UTC/Vortex) /// transportUsed is channelid.specific transport /// </summary> /// <param name="instrumentationKey"></param> /// <param name="userId"></param> /// <param name="overridedClientWrapper"></param> /// <param name="defaultChannelProperties"></param> public BaseAppInsightsSessionChannel(string instrumentationKey, string userId, IAppInsightsClientWrapper overridedClientWrapper = null, ChannelProperties defaultChannelProperties = ChannelProperties.NotForUnitTest) { appInsightsClient = overridedClientWrapper; InstrumentationKey = instrumentationKey; UserId = userId; channelProperties = defaultChannelProperties; transportUsed = new Lazy <string>(delegate { CodeContract.RequiresArgumentNotNull <IAppInsightsClientWrapper>(appInsightsClient, "appInsightsClient"); string text = ChannelId; if (appInsightsClient.TryGetTransport(out string str)) { text = text + "." + str; } return(text); });
private void OpenPlayerChannel([NotNull] string player, [NotNull] ChannelProperties config) { if (player == null) { throw new ArgumentNullException("player"); } if (config == null) { throw new ArgumentNullException("config"); } //If we don't know who this player is yet save the channel open event and process it later ClientInfo <TPeer?> info; if (!_peers.TryGetClientInfoByName(player, out info)) { _pendingPlayerChannels.Add(new KeyValuePair <string, ChannelProperties>(player, config)); return; } OpenChannel(ChannelType.Player, config, info.PlayerId, info.PlayerName); }
private void CloseChannel(ChannelType type, [NotNull] ChannelProperties properties, ushort id) { if (properties == null) { throw new ArgumentNullException("properties"); } using (var unlocker = _openChannels.Lock()) { var openChannels = unlocker.Value; //Find the channel and change it to a closing version of the channel for (var index = 0; index < openChannels.Count; index++) { var channel = openChannels[index]; if (!channel.IsClosing && channel.Type == type && channel.Recipient == id && ReferenceEquals(channel.Config, properties)) { openChannels[index] = channel.AsClosing(); } } } }
private void OpenChannel(ChannelType type, [NotNull] ChannelProperties config, ushort recipient, [NotNull] string name) { if (name == null) { throw new ArgumentNullException("name"); } if (config == null) { throw new ArgumentNullException("config"); } using (var unlocker = _openChannels.Lock()) { var openChannels = unlocker.Value; int index; //Check if we have a closing channel which we're now trying to re-open var reopened = false; for (index = 0; index < openChannels.Count; index++) { var c = openChannels[index]; if (c.Type == type && ReferenceEquals(c.Config, config) && c.Recipient == recipient) { openChannels[index] = c.AsOpen(); reopened = true; break; } } //Failed to find a channel to re-open so just add a new one if (!reopened) { openChannels.Add(new OpenChannel(type, 0, config, false, recipient, name)); } } }
private void CloseChannel(ChannelType type, ushort id, ChannelProperties properties) { lock (_openChannels) { var allClosing = true; int index; //Find the channel and change it to a closing version of the channel //As we go, accumulate a flag indicating if *all* channels are currently closing for (index = 0; index < _openChannels.Count; index++) { var channel = _openChannels[index]; if (!channel.IsClosing && channel.Type == type && channel.Recipient == id && ReferenceEquals(channel.Config, properties)) { _openChannels[index] = channel.AsClosing(); break; } else { allClosing &= channel.IsClosing; } } //Finish off accumulating that flag for (; index < _openChannels.Count; index++) { allClosing &= _openChannels[index].IsClosing; } //All channels are closing, bump up the session ID so the receiving end can tell if (allClosing) { unchecked { _sessionId++; } } } }
public static extern uint ts3client_getChannelVariableAsString(uint64 arg0, uint64 arg1, ChannelProperties arg2, out IntPtr arg3);
public ChannelChangedEventArgs(ChannelProperties p_propertie) { ChannelProperties = p_propertie; }
private static extern uint SetChannelVariableAsString(ulong serverID, ChannelProperties flag, string value);
private static extern uint SetChannelVariableAsInt(ulong serverID, ChannelProperties flag, int value);
private void CloseRoomChannel(string roomName, ChannelProperties config) { CloseChannel(ChannelType.Room, roomName.ToRoomId(), config); }
public WatsonSessionChannelBuilder(int faultEventSamplePercent, int faultEventMaximumWatsonReportsPerSession, int faultEventMinimumSecondsBetweenWatsonReports, ChannelProperties properties) { this.faultEventSamplePercent = faultEventSamplePercent; this.faultEventMaximumWatsonReportsPerSession = faultEventMaximumWatsonReportsPerSession; this.faultEventMinimumSecondsBetweenWatsonReports = faultEventMinimumSecondsBetweenWatsonReports; this.properties = properties; }
public static uint GetChannelVariableAsStr(ulong serverConnectionHandlerID, ulong channelID, ChannelProperties property, ref string ptr) { var funcs = MyFirstPlugin.Instance.Functions; IntPtr refs = IntPtr.Zero; uint reter = (funcs.getChannelVariableAsString(serverConnectionHandlerID, channelID, EnumIntPtr(property), ref refs)); ptr = Marshal.PtrToStringAnsi(refs); return reter; }
public bool setIntVariable(ulong serverID, ulong channelID, ChannelProperties property, int value) { if (SetChannelVariableAsInt(_connectedServerID, channelID, property, value) != Error.ok) { notifyError(string.Format("Error setting variable: {0}", property.ToString())); return false; } return true; }
static extern uint SetChannelVariableAsulong(ulong serverID, ulong channelID, ChannelProperties flag, ulong value);
static extern uint GetChannelVariableAsulong(ulong serverID, ulong channelID, ChannelProperties flag, out ulong result);
private static extern uint GetChannelVariableAsString(ulong serverID, ulong channelID, ChannelProperties flag, out IntPtr result);
public static extern uint getChannelVariableAsString(uint64 arg0, uint64 arg1, ChannelProperties arg2, out IntPtr arg3);
public int getIntVariable(ulong channelID, ChannelProperties property) { int value = 0; if (GetChannelVariableAsInt(_connectedServerID, channelID, property, out value) != Error.ok) { notifyError(string.Format("Error getting variable: {0}", property.ToString())); return 0; } return value; }
public static unsafe uint GetChannelVariableAsStr(ulong serverConnectionHandlerID, ulong channelID, ChannelProperties property, ref string ptr) { var funcs = TSPlugin.Instance.Functions; IntPtr refs = IntPtr.Zero; uint reter = (funcs.getChannelVariableAsString(serverConnectionHandlerID, channelID, new IntPtr((int)property), ref refs)); ptr = Marshal.PtrToStringAnsi(refs); return(reter); }
private void TriggerOnPropertyChanged(ChannelProperties p_properties) { OnPropertyChanged(this, new ChannelChangedEventArgs(p_properties)); }
/* public bool setStringVariable(ulong serverID, ulong channelID, ChannelProperties property, string value) { if (SetChannelVariableAsString(serverID, channelID, property, value) != Error.ok) { notifyError(string.Format("Error setting variable: {0}", property.ToString())); return false; } return true; } public bool setStringVariable(ulong serverID, ulong channelID, ClientProperties property, string value) { if (SetClientSelfVariableAsString(serverID, property, value) != Error.ok) { notifyError(string.Format("Error setting variable: {0}", property.ToString())); return false; } return true; } public bool setIntVariable(ulong serverID, ulong channelID, ChannelProperties property, int value) { if (SetChannelVariableAsInt(serverID, channelID, property, value) != Error.ok) { notifyError(string.Format("Error setting variable: {0}", property.ToString())); return false; } return true; } public bool setIntVariable(ulong serverID, ulong channelID, ClientProperties property, int value) { if (SetClientSelfVariableAsInt(serverID, property, value) != Error.ok) { notifyError(string.Format("Error setting variable: {0}", property.ToString())); return false; } return true; } public string getStringVariable(ulong serverID, VirtualServerProperties property) { IntPtr valuePtr = IntPtr.Zero; uint result = Error.ok; if ((result = GetServerVariableAsString(serverID, property, out valuePtr)) != Error.ok) { notifyError(string.Format("Error getting variable: {0}", property.ToString())); return string.Empty; } return getStringFromPointer(valuePtr); } */ public string getStringVariable(ulong channelID, ChannelProperties property) { IntPtr valuePtr = IntPtr.Zero; uint result = Error.ok; if ((result = GetChannelVariableAsString(_serverID, channelID, property, out valuePtr)) != Error.ok) { notifyError(string.Format("Error getting variable: {0}", property.ToString())); return string.Empty; } return getStringFromPointer(valuePtr); }
private void OpenRoomChannel(string roomName, ChannelProperties config) { OpenChannel(ChannelType.Room, config, roomName.ToRoomId()); }
public async Task IdleChannelClosureAsyncTest() { using (FaultyServer server = new FaultyServer()) { try { await server.StartAsync(); TimeSpan runTime = TimeSpan.FromSeconds(45.0); Stopwatch sw = Stopwatch.StartNew(); Guid activityId = Guid.NewGuid(); Trace.CorrelationManager.ActivityId = activityId; ChannelProperties channelProperties = new ChannelProperties( new UserAgentContainer(), certificateHostNameOverride: "localhost", requestTimerPool: new TimerPool(1), requestTimeout: TimeSpan.FromSeconds(3.0), openTimeout: TimeSpan.FromSeconds(3.0), maxChannels: ushort.MaxValue, partitionCount: 1, maxRequestsPerChannel: 100, receiveHangDetectionTime: TimeSpan.FromSeconds(11.0), sendHangDetectionTime: TimeSpan.FromSeconds(3.0), idleTimeout: TimeSpan.FromSeconds(5), idleTimerPool: new TimerPool(1)); using (Channel channel = new Channel( server.Uri, channelProperties)) { AutoResetEvent initializationEvent = new AutoResetEvent(initialState: false); ManualResetEventSlim connectionClosedEvent = new ManualResetEventSlim(initialState: false); channel.OnInitializationComplete += () => { Trace.WriteLine("channel initialization event is fired"); initializationEvent.Set(); }; channel.SubscribeToConnectionClosure(() => { Trace.WriteLine("channel connection closure event is fired"); connectionClosedEvent.Set(); }); channel.Initialize(activityId); Assert.IsTrue(initializationEvent.WaitOne()); Trace.WriteLine("channel initialization completes"); Assert.IsTrue(channel.Healthy); Assert.IsFalse(connectionClosedEvent.IsSet); Trace.WriteLine($"Start waiting for idle: {DateTime.UtcNow}"); bool isChannelIdleAndClosed = false; while (sw.Elapsed < runTime) { if (!channel.Healthy) { Assert.IsTrue(channel.IsIdle); Trace.WriteLine($"Idle: {DateTime.UtcNow}"); if (connectionClosedEvent.Wait(TimeSpan.FromSeconds(2))) { Trace.WriteLine($"Connection closed: {DateTime.UtcNow}"); sw.Stop(); isChannelIdleAndClosed = true; break; } } await Task.Delay(TimeSpan.FromSeconds(2)); } Assert.IsTrue(isChannelIdleAndClosed); Assert.IsTrue(sw.Elapsed < runTime); } } finally { await server.StopAsync(); } } }