ProcessBootstrap.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.Remoting;
  5. using System.Runtime.Remoting.Channels;
  6. using System.Runtime.Remoting.Channels.Ipc;
  7. using System.Text;
  8. using SuperSocket.SocketBase;
  9. using SuperSocket.SocketBase.Config;
  10. using SuperSocket.SocketBase.Logging;
  11. using SuperSocket.SocketBase.Provider;
  12. using SuperSocket.SocketBase.Metadata;
  13. namespace SuperSocket.SocketEngine
  14. {
  15. class DefaultBootstrapProcessWrap : DefaultBootstrapAppDomainWrap
  16. {
  17. public DefaultBootstrapProcessWrap(IBootstrap bootstrap, IConfigurationSource config, string startupConfigFile)
  18. : base(bootstrap, config, startupConfigFile)
  19. {
  20. }
  21. protected override IWorkItem CreateWorkItemInstance(string serviceTypeName, StatusInfoAttribute[] serverStatusMetadata)
  22. {
  23. return new ProcessAppServer(serviceTypeName, serverStatusMetadata);
  24. }
  25. }
  26. class ProcessBootstrap : AppDomainBootstrap
  27. {
  28. /// <summary>
  29. /// Initializes a new instance of the <see cref="ProcessBootstrap" /> class.
  30. /// </summary>
  31. /// <param name="config">The config.</param>
  32. public ProcessBootstrap(IConfigurationSource config)
  33. : base(config)
  34. {
  35. var clientChannel = ChannelServices.RegisteredChannels.FirstOrDefault(c => c is IpcClientChannel);
  36. if(clientChannel == null)
  37. {
  38. // Create the channel.
  39. clientChannel = new IpcClientChannel();
  40. // Register the channel.
  41. ChannelServices.RegisterChannel(clientChannel, false);
  42. }
  43. }
  44. protected override IBootstrap CreateBootstrapWrap(IBootstrap bootstrap, IConfigurationSource config, string startupConfigFile)
  45. {
  46. return new DefaultBootstrapProcessWrap(bootstrap, config, startupConfigFile);
  47. }
  48. }
  49. }