/[dgee]/dgee/cslib/DotGNU/DGEE/Protocols/XmlRpc/XmlRpcProtocolHandler.cs
ViewVC logotype

Diff of /dgee/cslib/DotGNU/DGEE/Protocols/XmlRpc/XmlRpcProtocolHandler.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by npg, Tue Jul 29 01:42:03 2003 UTC revision 1.2 by csmith, Sun Sep 21 10:55:47 2003 UTC
# Line 0  Line 1 
1    /*
2     * DotGNU DGEE Protocol Service
3     *
4     * Copyright (C) 2003 DotGNU Project
5     *
6     * This program is free software; you can redistribute it and/or modify
7     * it under the terms of the GNU General Public License as published by
8     * the Free Software Foundation; either version 2 of the License, or
9     * (at your option) any later version.
10     *
11     * This program is distributed in the hope that it will be useful,
12     * but WITHOUT ANY WARRANTY; without even the implied warranty of
13     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     * GNU General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with this program; if not, write to the Free Software
18     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19     *
20     * $Revision$  $Date$
21     *
22     * --------------------------------------------------------------------------
23     *
24     * Authors:
25     *   Nicolai P Guba
26     */
27    using System;
28    using System.IO;
29    using System.Collections;
30    using DotGNU.XmlRpc.Serialization.Formatters;
31    using DotGNU.XmlRpc;
32    
33    namespace DotGNU.DGEE.Protocols
34    {
35      public class XmlRpcProtocolHandler : IProtocolHandler
36      {
37        MethodCallFormatter requestFormat = new MethodCallFormatter();
38        MethodResponseFormatter replyFormat = new MethodResponseFormatter();
39    
40        public object Request( StreamReader input )
41        {
42          // Handle any incoming request
43          #if __DEBUG__
44          Console.Out.WriteLine( ">>> Request" );
45          #endif
46    
47    
48          // Determine the method from the protocol
49          XmlRpcMethod method = (XmlRpcMethod)requestFormat.Deserialize( input.BaseStream );
50          #if __DEBUG__
51          Console.Out.WriteLine( "--- Deserialising Request" );
52          Console.Out.WriteLine( method );
53          #endif
54    
55          return method;
56        }
57            
58        public void Error( Stream output )
59        {
60        }
61        
62        public void Response( StreamWriter output, object o )
63        {
64          // Serialise the result of the method
65          #if __DEBUG__
66          Console.WriteLine( "--- Serialising Response (Type {0})", o.GetType().ToString() );
67          #endif
68    
69          // FIXME ??????
70              // Nicolai, you had this:
71              //
72          // replyFormat.Serialize( output.BaseStream, (XmlRpcResponse)o );
73              //
74              // but I had to do the following instead....
75              // What were you getting at with XmlRpcResponse being an 'array' ?
76              // I assume you were thinking further ahead to when responses may be
77              // more than just a single object ?
78              // Mind you: XmlRpc may only return a single object (which can be an
79              //  array or struct of course).
80              // So what we have here may be over the top.  XmlRpcResponse may not need
81              // to be an array at all.
82              //
83              // I don't know enough of your design to qualify to change any of this :o)
84              // This is enough to get it working.
85          //
86              XmlRpcResponse resp = new XmlRpcResponse();
87              resp.Add( o );
88          replyFormat.Serialize( output.BaseStream, resp );
89          
90          // Send it back to the client
91          #if __DEBUG__
92          Console.WriteLine( "<<< Response" );
93          #endif
94        }
95      }
96    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26