(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Runtime.Remoting / System.Runtime.Remoting.Channels.Http / HttpChannel.cs
blobf39d71f47912189f2bee084bc9941702ac248934
1 //
2 // System.Runtime.Remoting.Channels.Http.HttpChannel
3 //
4 // Summary: Implements a wrapper class for HTTP client and server channels.
5 //
6 // Classes: public HttpChannel
7 //
8 // Authors:
9 // Martin Willemoes Hansen (mwh@sysrq.dk)
10 // Ahmad Tantawy (popsito82@hotmail.com)
11 // Ahmad Kadry (kadrianoz@hotmail.com)
12 // Hussein Mehanna (hussein_mehanna@hotmail.com)
14 // (C) 2003 Martin Willemoes Hansen
18 // Permission is hereby granted, free of charge, to any person obtaining
19 // a copy of this software and associated documentation files (the
20 // "Software"), to deal in the Software without restriction, including
21 // without limitation the rights to use, copy, modify, merge, publish,
22 // distribute, sublicense, and/or sell copies of the Software, and to
23 // permit persons to whom the Software is furnished to do so, subject to
24 // the following conditions:
25 //
26 // The above copyright notice and this permission notice shall be
27 // included in all copies or substantial portions of the Software.
28 //
29 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
30 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
32 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
33 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
34 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
35 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38 using System;
39 using System.Collections;
40 using System.Runtime.Remoting.Messaging;
42 namespace System.Runtime.Remoting.Channels.Http
44 public class HttpChannel: BaseChannelWithProperties, IChannelReceiver,
45 IChannelSender, IChannel, IChannelReceiverHook
47 private HttpServerChannel serverChannel;
48 private HttpClientChannel clientChannel;
49 private string channelName = "http";
50 private int channelPriority = 1;
51 private AggregateDictionary properties;
53 public HttpChannel()
55 SetupChannel (new Hashtable(), null, null);
58 public HttpChannel (int port)
60 Hashtable prop = new Hashtable();
61 prop["port"] = port;
62 SetupChannel(prop,null,null);
65 public HttpChannel (IDictionary properties,IClientChannelSinkProvider clientSinkProvider,IServerChannelSinkProvider serverSinkProvider)
67 SetupChannel (properties,clientSinkProvider,serverSinkProvider);
70 private void SetupChannel (IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
72 clientChannel = new HttpClientChannel (properties, clientSinkProvider);
73 serverChannel = new HttpServerChannel (properties, serverSinkProvider);
75 object val = properties ["name"];
76 if (val != null) channelName = val as string;
78 val = properties ["priority"];
79 if (val != null) channelPriority = Convert.ToInt32 (val);
81 this.properties = new AggregateDictionary (new IDictionary[] {clientChannel, serverChannel});
85 //IChannel Members
86 public String ChannelName
88 get { return channelName; }
91 public int ChannelPriority
93 get { return channelPriority; }
96 public String Parse(String url, out String objectURI)
98 return HttpHelper.Parse(url, out objectURI);
101 //IChannelSender Members
102 public IMessageSink CreateMessageSink(String url, Object remoteChannelData, out String objectURI)
104 return clientChannel.CreateMessageSink(url, remoteChannelData, out objectURI);
107 //IChannelReciever Members
108 public String[] GetUrlsForUri(String objectURI)
110 return serverChannel.GetUrlsForUri(objectURI);
113 public void StartListening(Object data)
115 serverChannel.StartListening(data);
118 public void StopListening(Object data)
120 serverChannel.StopListening(data);
123 public Object ChannelData
125 get { return serverChannel.ChannelData; }
128 public String ChannelScheme
130 get { return "http"; }
133 public bool WantsToListen
135 get { return serverChannel.WantsToListen; }
136 set { serverChannel.WantsToListen = value; }
139 public IServerChannelSink ChannelSinkChain
141 get { return serverChannel.ChannelSinkChain; }
144 public void AddHookChannelUri (String channelUri)
146 serverChannel.AddHookChannelUri (channelUri);
149 public override object this [object key]
151 get { return properties[key]; }
152 set { properties[key] = value; }
155 public override ICollection Keys
157 get { return properties.Keys; }
160 public override IDictionary Properties
162 get { return properties; }