예제 #1
0
        /// <summary>
        /// This command allows you to listen to events that the client encounters. Events
        /// are things like people starting or stopping to talk, people joining or leaving,
        /// new channels being created and many more. It registers for client notifications
        /// for the specified serverConnectionHandlerId. If the serverConnectionHandlerID
        /// is set to null it applies to all server connection handlers.
        /// </summary>
        /// <param name="event">The event to register for. Choose ClientNotifyRegisterEvent.Any to register for all events.</param>
        /// <param name="serverConnectionHandlerId">The id of the server connection handler.</param>
        public SimpleResponse RegisterForNotifications(ClientNotifyRegisterEvent @event, uint?serverConnectionHandlerId = null)
        {
            Command command = CommandName.ClientNotifyRegister.CreateCommand();

            command.AddParameter("event", @event.ToString().ToLower());
            command.AddParameter("schandlerid", serverConnectionHandlerId.HasValue ? serverConnectionHandlerId.Value : 0);

            return(ResponseBase <SimpleResponse> .Parse(SendCommand(command)));
        }
예제 #2
0
        /// <summary>
        /// Gets channel connection information for the provided channel id from the currently selected server connection handler. If the provided id is null, the current channel id is used.
        /// </summary>
        /// <param name="channelId">The channel id to get the info for. Null for the current channel</param>
        public ChannelConnectionInfoResponse GetChannelConnectionInfo(uint?channelId)
        {
            Command command = CommandName.ChannelConnectInfo.CreateCommand();

            if (channelId.HasValue)
            {
                command.AddParameter("cid", channelId.Value);
            }

            return(ResponseBase <ChannelConnectionInfoResponse> .Parse(SendCommand(command)));
        }
예제 #3
0
        /// <summary>
        /// Selects the server connection handler.
        /// </summary>
        /// <param name="serverConnectionHandlerId">The id of the server connection handler to select. If set to null, the currently active connection handler is selected.</param>
        public SingleValueResponse <uint> SelectServerConnectionHandler(uint?serverConnectionHandlerId)
        {
            Command command = SharedCommandName.Use.CreateCommand();

            if (serverConnectionHandlerId.HasValue)
            {
                command.AddParameter("schandlerid", serverConnectionHandlerId.Value);
            }

            return(ResponseBase <SingleValueResponse <uint> > .Parse(SendCommand(command), "schandlerid"));
        }
예제 #4
0
        /// <summary>
        /// Sets one or more values concerning your own client, and makes them available to other clients through the server where applicable
        /// </summary>
        /// <param name="modificationInstance">The modifications as class</param>
        public SimpleResponse UpdateClient(ClientModification modificationInstance)
        {
            if (modificationInstance == null)
            {
                throw new ArgumentNullException("modificationInstance");
            }

            Command command = SharedCommandName.ClientUpdate.CreateCommand();

            modificationInstance.AddToCommand(command);

            return(ResponseBase <SimpleResponse> .Parse(SendCommand(command)));
        }
예제 #5
0
        /// <summary>
        /// Authenticate against the local query client
        /// </summary>
        /// <param name="apiKey">The api key used to authenticate</param>
        public SimpleResponse Authenticate(string apiKey)
        {
            Command command = CommandName.Auth.CreateCommand();

            if (apiKey == null)
            {
                throw new ArgumentNullException("apiKey");
            }

            command.AddParameter("apikey", apiKey);

            return(ResponseBase <SimpleResponse> .Parse(SendCommand(command)));
        }
예제 #6
0
        public ResponseBase <T> SendMethod <T>(string method, params object[] parameters) where T : ResponseBase <T>
        {
            uint   messageID = GetUniqueMessageID();
            string xml       = RPCCommand.GetMethodCallElementWithXmlDeclaration(method, parameters).ToString(SaveOptions.DisableFormatting);

            Send(xml, messageID);
            string response = GetMethodResponse(messageID);

            XElement messageElement = TryParseXElement(response);

            if (messageElement == null)
            {
                throw new FormatException(string.Format("The response could not be transformed into a XElement.\nMethod: {0}\nSent XML: \n{1}\nResponse:\n{2}", method, xml, response));
            }

            return(ResponseBase <T> .Parse(messageElement));
        }
예제 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="receiveData"></param>
        /// <param name="response"></param>
        /// <returns></returns>
        public bool HasNextPackage(string receiveData, out ResponseBase response)
        {
            response = null;

            if (string.IsNullOrEmpty(receiveData))
            {
                return(false);
            }

            var m_parseByte = false;

            try
            {
                response = (ResponseBase)ResponseBase.Parse(typeof(ResponseBase), receiveData, m_parseByte);
                return(int.Parse(response.ReqHeader.PackSeq) < int.Parse(response.ReqHeader.PackCount));
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message, FXConsts.SOCKET);
                return(false);
            }
        }
예제 #8
0
 /// <summary>
 /// Displays information about your current ServerQuery connection including the ID of the selected virtual server, your loginname, etc.
 /// </summary>
 public WhoAmIResponse SendWhoAmI()
 {
     return(ResponseBase <WhoAmIResponse> .Parse(SendCommand(SharedCommandName.WhoAmI.CreateCommand())));
 }
예제 #9
0
        /// <summary>
        /// Returns a list of currently active server connection handler ids
        /// </summary>
        /// <returns>A list of ids</returns>
        public ListResponse <uint> GetServerConnectionHandlerIdList()
        {
            Command command = CommandName.ServerConnectionHandlerList.CreateCommand();

            return(ResponseBase <ListResponse <uint> > .Parse(SendCommand(command), "schandlerid"));
        }
예제 #10
0
 /// <summary>
 /// Closes the ServerQuery connection to the TeamSpeak 3 Server instance.
 /// </summary>
 public SimpleResponse Quit()
 {
     return(ResponseBase <SimpleResponse> .Parse(SendCommand(SharedCommandName.Quit.CreateCommand())));
 }