SendData() public method

public SendData ( byte data ) : void
data byte
return void
Esempio n. 1
0
        public int Request(string action, string requestXML)
        {
            int returnId = requestId;

            if (daemonIsConnected)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(String.Format("<Request requestId=\"{0}\" action=\"{1}\"", requestId++, action));
                if (string.IsNullOrEmpty(requestXML))
                {
                    sb.Append(" />");
                }
                else
                {
                    sb.Append(">");
                    sb.Append(requestXML);
                    sb.Append("</Request>");
                }
                sb.Append("\n\n\n");

                daemonPipe.SendData(Encoding.ASCII.GetBytes(sb.ToString()));
                return(returnId);
            }
            else
            {
                return(-1);
            }
        }
Esempio n. 2
0
        public int Request(string action, string requestXML)
        {
            int returnId = requestId;

            if (daemonIsConnected)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(String.Format("<Request requestId=\"{0}\" action=\"{1}\"", requestId++, action));
                if (string.IsNullOrEmpty(requestXML))
                {
                    sb.Append(" />");
                }
                else
                {
                    sb.Append(">");
                    sb.Append(requestXML);
                    sb.Append("</Request>");
                }
                sb.Append("\n\n\n");

#if DEBUG
                Logger.Log("Request: " + sb.ToString(), Helpers.LogLevel.Debug);
#endif
                try
                {
                    daemonPipe.SendData(Encoding.ASCII.GetBytes(sb.ToString()));
                }
                catch
                {
                    returnId = -1;
                }

                return(returnId);
            }
            else
            {
                return(-1);
            }
        }