예제 #1
0
        private Readable SendRequest(Writeable payload)
        {
            // build the request header
            PlayerRqst request = CreateHeader(payload);

            // build request data
            MemoryStream  requestStream = new MemoryStream();
            XmlDataWriter requestWriter = new XmlDataWriter(requestStream);

            requestWriter.WriteObject(request.GetType().Name, request);
            requestWriter.Flush();
            if (Logger.Enabled)
            {
                Logger.LogInfo(this, "SendRequest", String.Format("Request: {0}", Encoding.UTF8.GetString(requestStream.ToArray())));
            }

            // send request
            MemoryStream responseStream = SendRequestViaHttp(requestStream);

            if (Logger.Enabled)
            {
                Logger.LogInfo(this, "SendRequest", String.Format("Response: {0}", Encoding.UTF8.GetString(responseStream.ToArray())));
            }

            // read response
            XmlDataReader responseReader = new XmlDataReader(responseStream);
            PlayerResp    response       = (PlayerResp)responseReader.ReadObject("PlayerResp", PlayerResp.CtorDataReader);

            // parse response header
            return(ParseHeader(response));
        }
예제 #2
0
        /* Save, file is read-only*/
        private void WriteDataFile(Stream stream, Config config)
        {
            stream.Seek(0, SeekOrigin.Begin);
            stream.SetLength(0);
            XmlDataWriter writer = new XmlDataWriter(stream);

            try
            {
                writer.PrettyPrint = true;
                writer.WriteObject(ConfigElement, config);
            }
            finally
            {
                writer.Close();
            }
        }