+2002-09-03 Dietmar Maurer <dietmar@ximian.com>
+
+ * System.Runtime.Remoting.Channels.CORBA/CORBAChannel.cs:
+ impl. the channel wrapper.
+
+ * System.Runtime.Remoting.Channels.Simple/SimpleChannel.cs:
+ impl. the channel wrapper.
+
+ * System.Runtime.Remoting.Channels.Simple/SimpleServerChannel.cs
+ (GetUrlsForUri): use all available channel uris.
+
2002-08-30 Dietmar Maurer <dietmar@ximian.com>
* System.Runtime.Remoting.Channels.Simple/SimpleWireFormat.cs: add
public class CORBAChannel : IChannelReceiver, IChannel,
IChannelSender
{
- private int tcp_port;
+ CORBAServerChannel svr_chnl;
+ CORBAClientChannel cnt_chnl;
+ string name = "corba";
+
public CORBAChannel ()
{
- tcp_port = 0;
+ svr_chnl = new CORBAServerChannel (0);
+ cnt_chnl = new CORBAClientChannel ();
}
public CORBAChannel (int port)
{
- tcp_port = port;
+ svr_chnl = new CORBAServerChannel (port);
+ cnt_chnl = new CORBAClientChannel ();
}
[MonoTODO]
public CORBAChannel (IDictionary properties,
- IClientChannelSinkProvider clientSinkProvider,
- IServerChannelSinkProvider serverSinkProvider)
+ IClientChannelSinkProvider clientSinkProvider,
+ IServerChannelSinkProvider serverSinkProvider)
{
throw new NotImplementedException ();
}
public object ChannelData
{
- [MonoTODO]
get {
- throw new NotImplementedException ();
+ return svr_chnl.ChannelData;
}
}
public string ChannelName
{
- [MonoTODO]
get {
- throw new NotImplementedException ();
+ return name;
}
}
public int ChannelPriority
{
- [MonoTODO]
get {
- throw new NotImplementedException ();
+ return svr_chnl.ChannelPriority;
}
}
- [MonoTODO]
public IMessageSink CreateMessageSink (string url,
object remoteChannelData,
out string objectURI)
{
- throw new NotImplementedException ();
+ return cnt_chnl.CreateMessageSink (url, remoteChannelData, out objectURI);
}
- [MonoTODO]
public string[] GetUrlsForUri (string objectURI)
{
- throw new NotImplementedException ();
+ return svr_chnl.GetUrlsForUri (objectURI);
}
public string Parse (string url, out string objectURI)
{
- int port;
-
- string host = ParseCORBAURL (url, out objectURI, out port);
-
- return "corba://" + host + ":" + port;
+ return svr_chnl.Parse (url, out objectURI);
}
- [MonoTODO]
public void StartListening (object data)
{
- throw new NotImplementedException ();
+ svr_chnl.StartListening (data);
}
- [MonoTODO]
public void StopListening (object data)
{
- throw new NotImplementedException ();
+ svr_chnl.StopListening (data);
}
internal static string ParseCORBAURL (string url, out string objectURI, out int port)
}
}
- public string GetChannelUri ()
+ string GetChannelUri ()
{
- return "tcp://" + host + ":" + port;
+ return "corba://" + host + ":" + port;
}
public string[] GetUrlsForUri (string uri)
{
- string [] result = new String [1];
-
+ string [] chnl_uris = channel_data.ChannelUris;
+
if (uri.IndexOf ('/') != 0)
- result [0] = GetChannelUri () + "/" + uri;
- else
- result [0] = GetChannelUri () + uri;
+ uri = "/" + uri;
+
+ string [] result = new String [chnl_uris.Length];
+ for (int i = 0; i < chnl_uris.Length; i++) {
+ result [i] = chnl_uris [i] + uri;
+ }
+
return result;
}
string host = CORBAChannel.ParseCORBAURL (url, out objectURI, out port);
- return "corba://" + host + ":" + port;
+ return GetChannelUri ();
}
void WaitForConnections ()
public class SimpleChannel : IChannelReceiver, IChannel,
IChannelSender
{
- private int tcp_port;
+ SimpleServerChannel svr_chnl;
+ SimpleClientChannel cnt_chnl;
+ string name = "simple";
+
public SimpleChannel ()
{
- tcp_port = 0;
+ svr_chnl = new SimpleServerChannel (0);
+ cnt_chnl = new SimpleClientChannel ();
}
public SimpleChannel (int port)
{
- tcp_port = port;
+ svr_chnl = new SimpleServerChannel (port);
+ cnt_chnl = new SimpleClientChannel ();
}
[MonoTODO]
public object ChannelData
{
- [MonoTODO]
get {
- throw new NotImplementedException ();
+ return svr_chnl.ChannelData;
}
}
public string ChannelName
{
- [MonoTODO]
get {
- throw new NotImplementedException ();
+ return name;
}
}
public int ChannelPriority
{
- [MonoTODO]
get {
- throw new NotImplementedException ();
+ return svr_chnl.ChannelPriority;
}
}
- [MonoTODO]
public IMessageSink CreateMessageSink (string url,
object remoteChannelData,
out string objectURI)
{
- throw new NotImplementedException ();
+ return cnt_chnl.CreateMessageSink (url, remoteChannelData, out objectURI);
}
- [MonoTODO]
public string[] GetUrlsForUri (string objectURI)
{
- throw new NotImplementedException ();
+ return svr_chnl.GetUrlsForUri (objectURI);
}
public string Parse (string url, out string objectURI)
{
- int port;
-
- string host = ParseSimpleURL (url, out objectURI, out port);
-
- return "tcp://" + host + ":" + port;
+ return svr_chnl.Parse (url, out objectURI);
}
- [MonoTODO]
public void StartListening (object data)
{
- throw new NotImplementedException ();
+ svr_chnl.StartListening (data);
}
- [MonoTODO]
public void StopListening (object data)
{
- throw new NotImplementedException ();
+ svr_chnl.StopListening (data);
}
internal static string ParseSimpleURL (string url, out string objectURI, out int port)
public class SimpleClientChannel : IChannelSender, IChannel
{
int priority = 1;
- string name = "tcp";
+ string name = "simple";
IClientChannelSinkProvider sink_provider;
public SimpleClientChannel ()
out string objectURI)
{
objectURI = null;
-
+
if (url != null) {
if (Parse (url, out objectURI) != null)
return (IMessageSink) sink_provider.CreateSink (this, url,
}
public SimpleServerChannel (IDictionary properties,
- IServerChannelSinkProvider serverSinkProvider)
+ IServerChannelSinkProvider serverSinkProvider)
{
port = (int)properties ["port"];
Init (serverSinkProvider);
}
}
- public string GetChannelUri ()
+ string GetChannelUri ()
{
- return "tcp://" + host + ":" + port;
+ return "simple://" + host + ":" + port;
}
public string[] GetUrlsForUri (string uri)
{
- string [] result = new String [1];
-
+ string [] chnl_uris = channel_data.ChannelUris;
+
if (uri.IndexOf ('/') != 0)
- result [0] = GetChannelUri () + "/" + uri;
- else
- result [0] = GetChannelUri () + uri;
+ uri = "/" + uri;
+ string [] result = new String [chnl_uris.Length];
+
+ for (int i = 0; i < chnl_uris.Length; i++) {
+ result [i] = chnl_uris [i] + uri;
+ }
+
return result;
}
string host = SimpleChannel.ParseSimpleURL (url, out objectURI, out port);
- return "tcp://" + host + ":" + port;
+ return GetChannelUri ();
}
void WaitForConnections ()
string url = "corba://localhost:8000/test";
string uri;
- IChannelReceiver svr_chnl = new CORBAServerChannel (8000);
-
- IChannel chnl = new CORBAClientChannel ();
+ CORBAChannel chnl = new CORBAChannel (8000);
+ ChannelServices.RegisterChannel (chnl);
Console.WriteLine ("Channel name: " + chnl.ChannelName);
Console.WriteLine ("Channel priority: " + chnl.ChannelPriority);
Console.WriteLine ("URI: " + chnl.Parse (url, out uri));
Console.WriteLine ("URI: " + uri);
- ChannelServices.RegisterChannel (chnl);
-
Test tp = (Test)RemotingServices.Connect (typeof (Test), url);
int res = tp.test_function (4, true);
Console.WriteLine ("RESULT: " + res);
- svr_chnl.StopListening (null);
+ chnl.StopListening (null);
return 0;
}
string url = "simple://localhost:8000/test";
string uri;
- IChannelReceiver svr_chnl = new SimpleServerChannel (8000);
-
- IChannel chnl = new SimpleClientChannel ();
+ SimpleChannel chnl = new SimpleChannel (8000);
+ ChannelServices.RegisterChannel (chnl);
Console.WriteLine ("Channel name: " + chnl.ChannelName);
Console.WriteLine ("Channel priority: " + chnl.ChannelPriority);
Console.WriteLine ("URI: " + chnl.Parse (url, out uri));
Console.WriteLine ("URI: " + uri);
- ChannelServices.RegisterChannel (chnl);
Test tp = (Test)RemotingServices.Connect (typeof (Test), url);
Console.WriteLine ("RESULT: " + res);
- svr_chnl.StopListening (null);
+ chnl.StopListening (null);
return 0;
}