2 // Mono.Remoting.Channels.Unix.UnixClientChannel.cs
4 // Author: Dietmar Maurer (dietmar@ximian.com)
5 // Lluis Sanchez Gual (lluis@novell.com)
7 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System
.Collections
;
34 using System
.Net
.Sockets
;
35 using System
.Runtime
.Remoting
.Messaging
;
36 using System
.Runtime
.Remoting
.Channels
;
37 using System
.Threading
;
39 namespace Mono
.Remoting
.Channels
.Unix
41 public class UnixClientChannel
: IChannelSender
, IChannel
45 IClientChannelSinkProvider _sinkProvider
;
47 public UnixClientChannel ()
49 _sinkProvider
= new UnixBinaryClientFormatterSinkProvider ();
50 _sinkProvider
.Next
= new UnixClientTransportSinkProvider ();
53 public UnixClientChannel (IDictionary properties
, IClientChannelSinkProvider sinkProvider
)
55 object val
= properties
["name"];
56 if (val
!= null) name
= val
as string;
58 val
= properties
["priority"];
59 if (val
!= null) priority
= Convert
.ToInt32 (val
);
61 if (sinkProvider
!= null)
63 _sinkProvider
= sinkProvider
;
65 // add the unix provider at the end of the chain
66 IClientChannelSinkProvider prov
= sinkProvider
;
67 while (prov
.Next
!= null) prov
= prov
.Next
;
68 prov
.Next
= new UnixClientTransportSinkProvider ();
70 // Note: a default formatter is added only when
71 // no sink providers are specified in the config file.
75 _sinkProvider
= new UnixBinaryClientFormatterSinkProvider ();
76 _sinkProvider
.Next
= new UnixClientTransportSinkProvider ();
81 public UnixClientChannel (string name
, IClientChannelSinkProvider sinkProvider
)
84 _sinkProvider
= sinkProvider
;
86 // add the unix provider at the end of the chain
87 IClientChannelSinkProvider prov
= sinkProvider
;
88 while (prov
.Next
!= null) prov
= prov
.Next
;
89 prov
.Next
= new UnixClientTransportSinkProvider ();
92 public string ChannelName
99 public int ChannelPriority
106 public IMessageSink
CreateMessageSink (string url
,
107 object remoteChannelData
,
108 out string objectURI
)
110 if (url
!= null && Parse (url
, out objectURI
) != null)
111 return (IMessageSink
) _sinkProvider
.CreateSink (this, url
, remoteChannelData
);
113 if (remoteChannelData
!= null) {
114 IChannelDataStore ds
= remoteChannelData
as IChannelDataStore
;
115 if (ds
!= null && ds
.ChannelUris
.Length
> 0)
116 url
= ds
.ChannelUris
[0];
123 if (Parse (url
, out objectURI
) == null)
126 return (IMessageSink
) _sinkProvider
.CreateSink (this, url
, remoteChannelData
);
129 public string Parse (string url
, out string objectURI
)
131 return UnixChannel
.ParseUnixURL (url
, out objectURI
);