Пример #1
0
 public static void Initialize()
 {
     AbstractFactory.Clear();
     ForgeRegistration.Initialize();
     RegisterFactoryInterfaces();
     SetupExtraSerializers();
 }
        private static void Main(string[] args)
        {
            ForgeRegistration.Initialize();
            var factory = AbstractFactory.Get <INetworkTypeFactory>();

            factory.Register <IRegisterAsServerInterpreter, RegisterAsServerInterpreter>();
            factory.Register <IGetServerRegistryInterpreter, GetServerRegistryInterpreter>();
            factory.Replace <INetPlayer, NetworkPlayer>();

            var networkMediator = factory.GetNew <INetworkMediator>();

            networkMediator.ChangeEngineProxy(new ServerRegistryEngine());
            networkMediator.StartServer(15940, 100);

            try
            {
                while (true)
                {
                    networkMediator.SocketFacade.CancellationSource.Token.ThrowIfCancellationRequested();
                    string line = Console.ReadLine().Trim();
                    switch (line)
                    {
                    case "exit":
                    case "quit":
                        networkMediator.SocketFacade.CancellationSource.Cancel();
                        break;

                    default:
                        Console.WriteLine($"This command isn't supported yet");
                        break;
                    }
                }
            }
            catch (OperationCanceledException) { }
        }
Пример #3
0
 public virtual void Setup()
 {
     ForgeRegistration.Initialize();
 }