public void AddToCommand(Command command) { AddToCommand(command, "channel_name", Name); AddToCommand(command, "channel_topic", Topic); AddToCommand(command, "channel_description", Description); AddToCommand(command, "channel_password", Password); if (Codec.HasValue) AddToCommand(command, "channel_codec", (uint)Codec.Value); AddToCommand(command, "channel_codec_quality", CodecQuality); AddToCommand(command, "channel_maxclients", MaxClients); AddToCommand(command, "channel_maxfamilyclients", MaxFamilyClients); AddToCommand(command, "channel_order", ChannelOrder); AddToCommand(command, "channel_flag_permanent", IsPermanent); AddToCommand(command, "channel_flag_semi_permanent", IsSemiPermanent); AddToCommand(command, "channel_flag_temporary", IsTemporary); AddToCommand(command, "channel_flag_default", IsDefault); AddToCommand(command, "channel_flag_maxclients_unlimited", HasUnlimitedMaxClients); AddToCommand(command, "channel_flag_maxfamilyclients_unlimited", HasUnlimitedMaxFamilyClients); AddToCommand(command, "channel_flag_maxfamilyclients_inherited", ArUnlimitedMaxFamilyClientsInherited); AddToCommand(command, "channel_needed_talk_power", NeededTalkPower); AddToCommand(command, "channel_name_phonetic", NamePhonetic); AddToCommand(command, "channel_icon_id", IconId); AddToCommand(command, "cpid", ParentChannelId); }
public void AddToCommand(Command command) { AddToCommand(command, "virtualserver_name", Name); AddToCommand(command, "virtualserver_welcomemessage", WelcomeMessage); AddToCommand(command, "virtualserver_maxclients", MaxClients); AddToCommand(command, "virtualserver_password", Password); AddToCommand(command, "virtualserver_hostmessage", HostMessage); if (HostMessageMode.HasValue) AddToCommand(command, "virtualserver_hostmessage_mode", (uint)HostMessageMode.Value); AddToCommand(command, "virtualserver_default_server_group", DefaultServerGroupId); AddToCommand(command, "virtualserver_default_channel_group", DefaultChannelGroupId); AddToCommand(command, "virtualserver_default_channel_admin_group", DefaultChannelAdminGroupId); AddToCommand(command, "virtualserver_max_download_total_bandwidth", MaxDownloadTotalBandwidth); AddToCommand(command, "virtualserver_max_upload_total_bandwidth", MaxUploadTotalBandwidth); AddToCommand(command, "virtualserver_hostbanner_url", HostBannerUrl); AddToCommand(command, "virtualserver_hostbanner_gfx_url", HostBannerGraphicsUrl); AddToCommand(command, "virtualserver_hostbanner_gfx_interval", HostBannerGraphicsInterval); AddToCommand(command, "virtualserver_complain_autoban_count", ComplainAutoBanCount); AddToCommand(command, "virtualserver_complain_autoban_time", ComplainAutoBanTime); AddToCommand(command, "virtualserver_complain_remove_time", ComplainRemoveTime); AddToCommand(command, "virtualserver_min_clients_in_channel_before_forced_silence", MinClientsInChannelBeforeForcedSilence); AddToCommand(command, "virtualserver_priority_speaker_dimm_modificator", PrioritySpeakerDimmModification); AddToCommand(command, "virtualserver_antiflood_points_tick_reduce", AntiFloodPointsTickReduce); AddToCommand(command, "virtualserver_antiflood_points_needed_warning", AntiFloodPointsNeededWarning); AddToCommand(command, "virtualserver_antiflood_points_needed_kick", AntiFloodPointsNeededKick); AddToCommand(command, "virtualserver_antiflood_points_needed_ban", AntiFloodPointsNeededBan); AddToCommand(command, "virtualserver_antiflood_points_ban_time", AntiFloodBanTime); AddToCommand(command, "virtualserver_hostbutton_tooltip", HostButtonTooltip); AddToCommand(command, "virtualserver_hostbutton_url", HostButtonUrl); AddToCommand(command, "virtualserver_download_quota", DownloadQuota); AddToCommand(command, "virtualserver_upload_quota", UploadQuota); AddToCommand(command, "virtualserver_machine_id", MachineId); AddToCommand(command, "virtualserver_port", Port); AddToCommand(command, "virtualserver_reserved_slots", ReservedSlots); AddToCommand(command, "virtualserver_autostart", AutoStart); AddToCommand(command, "virtualserver_needed_identity_security_level", NeededIdentitySecurityLevel); AddToCommand(command, "virtualserver_min_client_version", MinClientVersion); if (ServerStatus.HasValue) AddToCommand(command, "virtualserver_status", (uint)ServerStatus.Value); AddToCommand(command, "virtualserver_log_client", LogClient); AddToCommand(command, "virtualserver_log_query", LogQuery); AddToCommand(command, "virtualserver_log_permissions", LogPermission); AddToCommand(command, "virtualserver_log_channel", LogChannel); AddToCommand(command, "virtualserver_log_server", LogServer); AddToCommand(command, "virtualserver_log_filetransfer", LogFiletransfer); AddToCommand(command, "virtualserver_name_phonetic", PhoneticName); AddToCommand(command, "virtualserver_icon_id", IconId); AddToCommand(command, "virtualserver_hostbutton_gfx_url", HostButtonGraphicsUrl); if (HostBannerMode.HasValue) AddToCommand(command, "virtualserver_hostbanner_mode", (uint) HostBannerMode.Value); AddToCommand(command, "virtualserver_weblist_enabled", WeblistEnabled); }
/// <summary> /// Send the command to the undlerying socket /// </summary> /// <param name="command">The command to send</param> public string SendCommand(Command command) { CheckForDisposed(); if (command == null) throw new ArgumentNullException("command"); return Dispatcher.Dispatch(command); }
public override void AddToCommand(Command command) { base.AddToCommand(command); AddToCommand(command, "client_away", IsAway); AddToCommand(command, "client_away_message", AwayMessage); AddToCommand(command, "client_input_muted", IsInputMuted); AddToCommand(command, "client_output_muted", IsOutputMuted); AddToCommand(command, "client_input_deactivated", IsInputDeactivated); AddToCommand(command, "client_is_channel_commander", IsChannelCommander); AddToCommand(command, "client_nickname_phonetic", PhoneticNickname); AddToCommand(command, "client_flag_avatar", Avatar); AddToCommand(command, "client_meta_data", Metadata); AddToCommand(command, "client_default_token", Metadata); }
public void AddToCommand(Command command) { AddToCommand(command, "serverinstance_guest_serverquery_group", GuestServerQueryGroupId); AddToCommand(command, "serverinstance_filetransfer_port", FileTransferPort); AddToCommand(command, "serverinstance_max_download_total_bandwidth", MaxDownloadTotalBandwidth); AddToCommand(command, "serverinstance_max_upload_total_bandwidth", MaxUploadTotalBandwidth); AddToCommand(command, "serverinstance_template_serveradmin_group", TemplateServerAdminGroupId); AddToCommand(command, "serverinstance_template_serverdefault_group", TemplateServerDefaultGroupId); AddToCommand(command, "serverinstance_template_channeladmin_group", TemplateChannelAdminGroupId); AddToCommand(command, "serverinstance_template_channeldefault_group", TemplateChannelDefaultGroupId); AddToCommand(command, "serverinstance_serverquery_flood_commands", ServerQueryFloodCommandsCount); AddToCommand(command, "serverinstance_serverquery_flood_time", ServerQueryFloodRatingDuration); AddToCommand(command, "serverinstance_serverquery_ban_time", ServerQueryBanDuration); }
protected static void AddToCommand(Command command, string key, object value) { if (command == null) throw new ArgumentNullException("command"); if (value == null) return; if (key.IsNullOrTrimmedEmpty()) throw new ArgumentException("key is null or trimmed empty."); if (value is bool? || value is bool) command.AddParameter(key, ((bool) value) ? "1" : "0"); else if (value is TimeSpan? || value is TimeSpan) command.AddParameter(key, ((TimeSpan)value).TotalSeconds.ChangeTypeInvariant<string>()); else command.AddParameter(key, Convert.ToString(value, CultureInfo.InvariantCulture)); }
/// <summary> /// Sends a request for the current channel and raises the channel switched event /// </summary> private void RequestCurrentChannelInfo() { var command = new Command(string.Format("channelvariable {0}={1} {2} {3}", Properties.ChannelID, this.currentChannelID, Properties.ChannelName, Properties.ChannelDescription)); string result = this.CommandQueryRunner.SendCommand(command); // Parse the channel info string channelName = DecodeUtility.DecodeStringProperty(result, true, Properties.ChannelName); string channelDescription = DecodeUtility.DecodeStringProperty(result, true, Properties.ChannelDescription); logger.Info("New Channel Information: name={0} description={1}", channelName, channelDescription); this.RaiseClientChannelChanged(new ChannelEventArgs(new Channel(this.currentChannelID, channelName) { Description = channelDescription })); }
/// <summary> /// Updates the full channel list and raises the ChannelListUpdated event when done /// </summary> private void InitializeChannelList() { var command = new Command("channellist"); string result = this.CommandQueryRunner.SendCommand(command); if (result != null) { var channelStrings = result.Split('|'); foreach (var channelString in channelStrings) { var channelInfo = Channel.FromChannelString(channelString); if (!this.channels.ContainsKey(channelInfo.ID)) { if (this.channels.TryAdd(channelInfo.ID, channelInfo)) { this.RaiseChannelAdded(new ChannelEventArgs(channelInfo)); } } else { this.channels.AddOrUpdate(channelInfo.ID, channelInfo, (key, oldValue) => channelInfo); this.RaiseChannelUpdated(new ChannelEventArgs(channelInfo)); } } } }
/// <summary> /// Sends a message to the current channel's chat /// </summary> /// <param name="msg">The message to send</param> public void SendChannelMessage(string msg) { if (this.CommandQueryRunner != null) { logger.Info("Sending text message: {0}", msg); var command = new Command("sendtextmessage targetmode=2"); command.AddParameter("msg", msg); logger.Info("Command: {0}", command.ToString()); this.CommandQueryRunner.SendCommand(command); } }
/// <summary> /// Sends a command to change the current channel /// </summary> /// <param name="channelID"></param> public void ChangeChannel(uint channelID) { if (this.CommandQueryRunner != null) { logger.Info("Moving client to channel {0}", channelID); var command = new Command(string.Format("clientmove cid={0} clid={1}", channelID, this.currentClientID)); string restul = this.CommandQueryRunner.SendCommand(command); } }
/// <summary> /// Sends a request for the current channel and raises the channel switched event /// </summary> private void RequestCurrentChannelInfo() { logger.Info("Requesting current channel information"); var command = new Command(string.Format("channelvariable {0}={1} {2} {3}", Properties.ChannelID, this.currentChannelID, Properties.ChannelName, Properties.ChannelDescription)); string result = this.TsConnection.SendCommand(command); if (!string.IsNullOrEmpty(result)) { // Parse the channel info string channelName = DecodeUtility.DecodeStringProperty(result, true, Properties.ChannelName); string channelDescription = DecodeUtility.DecodeStringProperty(result, true, Properties.ChannelDescription); logger.Info("Channel Information: name={0} description={1}", channelName, channelDescription); this.RaiseClientChannelChanged(new ChannelEventArgs(new Channel(this.currentChannelID, channelName) { Description = channelDescription })); } }
private Channel getChannelInfo(string id) { Channel channel = new Channel(id); Command cmd = new Command("channelclientlist cid=" + id); string cmdResponse = QueryRunner.SendCommand(cmd); channel.clients = new Dictionary<string, Client>(); string[] users = cmdResponse.Split('|'); foreach (string user in users) { string clientId = Utils.GetParamFromString(user, "clid"); if (getClient(clientId)==null || getClient(clientId).id != myClient.id) { channel.clients.Add(clientId, getClientInfo(clientId)); } } cmd = new Command("channelvariable cid="+id+" channel_name"); cmdResponse = QueryRunner.SendCommand(cmd); channel.name= Utils.GetParamFromString(cmdResponse, "channel_name"); return channel; }
public override void AddToCommand(Command command) { base.AddToCommand(command); AddToCommand(command, "client_description", Description); AddToCommand(command, "client_is_talker", IsTalker); }
/// <summary> /// Sends a command to teamspeak /// </summary> /// <param name="command">The command to send</param> /// <returns>The result returned from teamspeak</returns> public string SendCommand(Command command) { lock (connectionLock) { if (this.CommandQueryRunner != null) { logger.Debug("Sending command: {0}", command); return this.CommandQueryRunner.SendCommand(command); } else { return string.Empty; } } }
public virtual void AddToCommand(Command command) { AddToCommand(command, "client_nickname", Nickname); }
/// <summary> /// Sends a message to the current channel's chat /// </summary> /// <param name="msg">The message to send</param> public void SendChannelMessage(string msg) { logger.Info("Sending text message: {0}", msg); var command = new Command("sendtextmessage targetmode=2"); command.AddParameter("msg", msg); logger.Info("Command: {0}", command.ToString()); this.TsConnection.SendCommand(command); }
/// <summary> /// Sends a command to change the current channel /// </summary> /// <param name="channelID"></param> public void ChangeChannel(uint channelID) { logger.Info("Moving client to channel {0}", channelID); var command = new Command(string.Format("clientmove cid={0} clid={1}", channelID, this.currentClientID)); this.TsConnection.SendCommand(command); }
private Client getClientInfo(string id) { Client client = new Client(id); Command cmd = new Command("clientvariable clid=" + id + " client_input_muted client_output_muted client_away client_nickname"); string cmdResponse = QueryRunner.SendCommand(cmd); client.nickname = Utils.GetParamFromString(cmdResponse, "client_nickname"); #region Statushandling string client_input_muted = Utils.GetParamFromString(cmdResponse, "client_input_muted"); string client_output_muted = Utils.GetParamFromString(cmdResponse, "client_output_muted"); string client_away = Utils.GetParamFromString(cmdResponse, "client_away"); if (client_away == "1") { client.state = clientState.away; } else if (client_output_muted == "1") { client.state = clientState.speaker_muted; } else if (client_input_muted == "1") { client.state = clientState.mic_muted; } else { client.state = clientState.normal; } #endregion return client; }
/// <summary> /// Updates the full channel list and raises the ChannelListUpdated event when done /// </summary> private void InitializeChannelList() { logger.Info("Initializing channel list"); var command = new Command("channellist"); string result = this.TsConnection.SendCommand(command); if (!string.IsNullOrEmpty(result)) { this.HandleChannelList(result); } }
private void QueryDispatcher_NotificationReceived(object sender, EventArgs<string> e) { Client client; switch (Notification.GetNotificationType(e.Value)) { case Notification.NotificationType.clientupdated: client = getClient(Utils.GetParamFromString(e.Value, "clid")); if (client != null) { Utils.updateClient(client, e.Value); } break; case Notification.NotificationType.talkstatuschange: client = getClient(Utils.GetParamFromString(e.Value, "clid")); if (client != null) { Utils.ChanceTalkStatus(client, e.Value); } break; case Notification.NotificationType.clientmoved: client = getClient(Utils.GetParamFromString(e.Value, "clid")); if (client != null) { if (client.id == myClient.id) { setupClientAndChannel(); } else { //TODO i cant think setupClientAndChannel(); } } else { client = getClientInfo(Utils.GetParamFromString(e.Value, "clid")); Command cmd = new Command("channelclientlist cid=" + myChannel.id); string cmdResponse = QueryRunner.SendCommand(cmd); string[] users = cmdResponse.Split('|'); foreach (string user in users) { if(client.id==Utils.GetParamFromString(user, "clid")) { if (!myChannel.clients.ContainsKey(client.id)) { myChannel.clients.Add(client.id, client); } } } } break; case Notification.NotificationType.clientchannelgroupchanged: break; } }