CORBAClientChannel.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // System.Runtime.Remoting.Channels.CORBA.CORBAClientChannel.cs
  3. //
  4. // Author: Dietmar Maurer ([email protected])
  5. //
  6. // 2002 (C) Copyright, Ximian, Inc.
  7. //
  8. using System.Collections;
  9. using System.IO;
  10. using System.Net.Sockets;
  11. using System.Runtime.Remoting.Messaging;
  12. using System.Runtime.Remoting.Channels;
  13. namespace System.Runtime.Remoting.Channels.CORBA
  14. {
  15. public class CORBAClientChannel : IChannelSender, IChannel
  16. {
  17. int priority = 1;
  18. string name = "corba";
  19. IClientChannelSinkProvider sink_provider;
  20. public CORBAClientChannel ()
  21. {
  22. sink_provider = new CORBAClientFormatterSinkProvider ();
  23. sink_provider.Next = new CORBAClientTransportSinkProvider ();
  24. }
  25. public CORBAClientChannel (IDictionary properties, IClientChannelSinkProvider sinkProvider)
  26. {
  27. priority = 1;
  28. sink_provider = sinkProvider;
  29. // add the tcp provider at the end of the chain
  30. IClientChannelSinkProvider prov = sinkProvider;
  31. while (prov.Next != null) prov = prov.Next;
  32. prov.Next = new CORBAClientTransportSinkProvider ();
  33. }
  34. public CORBAClientChannel (string name, IClientChannelSinkProvider sinkProvider)
  35. {
  36. priority = 1;
  37. this.name = name;
  38. sink_provider = sinkProvider;
  39. // add the tcp provider at the end of the chain
  40. IClientChannelSinkProvider prov = sinkProvider;
  41. while (prov.Next != null) prov = prov.Next;
  42. prov.Next = new CORBAClientTransportSinkProvider ();
  43. }
  44. public string ChannelName
  45. {
  46. get {
  47. return name;
  48. }
  49. }
  50. public int ChannelPriority
  51. {
  52. get {
  53. return priority;
  54. }
  55. }
  56. public IMessageSink CreateMessageSink (string url,
  57. object remoteChannelData,
  58. out string objectURI)
  59. {
  60. objectURI = null;
  61. if (url != null) {
  62. if (Parse (url, out objectURI) != null)
  63. return (IMessageSink) sink_provider.CreateSink (this, url,
  64. remoteChannelData);
  65. }
  66. if (remoteChannelData != null) {
  67. IChannelDataStore ds = remoteChannelData as IChannelDataStore;
  68. if (ds != null) {
  69. foreach (string chnl_uri in ds.ChannelUris) {
  70. if (Parse (chnl_uri, out objectURI) == null)
  71. continue;
  72. return (IMessageSink) sink_provider.CreateSink (this, chnl_uri,
  73. remoteChannelData);
  74. }
  75. }
  76. }
  77. return null;
  78. }
  79. public string Parse (string url, out string objectURI)
  80. {
  81. int port;
  82. string host = CORBAChannel.ParseCORBAURL (url, out objectURI, out port);
  83. return "corba://" + host + ":" + port;
  84. }
  85. }
  86. }