IpcServerChannel.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. //
  2. // System.Runtime.Remoting.Channels.Ipc.IpcServerChannel.cs
  3. //
  4. // Author: Robert Jordan ([email protected])
  5. //
  6. // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
  7. //
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. #if NET_2_0
  29. using System;
  30. using System.Collections;
  31. using System.Runtime.Remoting;
  32. using Unix = System.Runtime.Remoting.Channels.Ipc.Unix;
  33. using Win32 = System.Runtime.Remoting.Channels.Ipc.Win32;
  34. namespace System.Runtime.Remoting.Channels.Ipc
  35. {
  36. public class IpcServerChannel : IChannelReceiver, IChannel
  37. {
  38. IChannelReceiver _innerChannel;
  39. string _portName;
  40. public IpcServerChannel (string portName)
  41. {
  42. _portName = portName;
  43. if (IpcChannel.IsUnix)
  44. _innerChannel = new Unix.IpcServerChannel (portName);
  45. else
  46. _innerChannel = new Win32.IpcServerChannel (portName);
  47. }
  48. public IpcServerChannel (IDictionary properties,
  49. IServerChannelSinkProvider serverSinkProvider)
  50. {
  51. if (properties != null)
  52. _portName = properties ["portName"] as string;
  53. if (IpcChannel.IsUnix)
  54. _innerChannel = new Unix.IpcServerChannel (properties, serverSinkProvider);
  55. else
  56. _innerChannel = new Win32.IpcServerChannel (properties, serverSinkProvider);
  57. }
  58. public IpcServerChannel (string name, string portName,
  59. IServerChannelSinkProvider serverSinkProvider)
  60. {
  61. _portName = portName;
  62. if (IpcChannel.IsUnix)
  63. _innerChannel = new Unix.IpcServerChannel (name, portName, serverSinkProvider);
  64. else
  65. _innerChannel = new Win32.IpcServerChannel (name, portName, serverSinkProvider);
  66. }
  67. public IpcServerChannel (string name, string portName)
  68. {
  69. _portName = portName;
  70. if (IpcChannel.IsUnix)
  71. _innerChannel = new Unix.IpcServerChannel (name, portName);
  72. else
  73. _innerChannel = new Win32.IpcServerChannel (name, portName);
  74. }
  75. public string ChannelName
  76. {
  77. get { return ((IChannel)_innerChannel).ChannelName; }
  78. }
  79. public int ChannelPriority
  80. {
  81. get { return ((IChannel)_innerChannel).ChannelPriority; }
  82. }
  83. public string Parse (string url, out string objectUri)
  84. {
  85. return ((IChannel)_innerChannel).Parse (url, out objectUri);
  86. }
  87. public object ChannelData
  88. {
  89. get { return _innerChannel.ChannelData; }
  90. }
  91. public string[] GetUrlsForUri (string objectUri)
  92. {
  93. return _innerChannel.GetUrlsForUri (objectUri);
  94. }
  95. public void StartListening (object data)
  96. {
  97. _innerChannel.StartListening (data);
  98. }
  99. public void StopListening (object data)
  100. {
  101. _innerChannel.StopListening (data);
  102. }
  103. public string GetChannelUri ()
  104. {
  105. // There is no interface for this member,
  106. // so we cannot delegate to the inner channel.
  107. return Win32.IpcChannelHelper.SchemeStart + _portName;
  108. }
  109. }
  110. }
  111. #endif