Exemplo n.º 1
0
        public async Task Run()
        {
            var options = _container.GetInstance <WvsLoginOptions>();
            var info    = options.LoginInfo;

            LoginInformation = new LoginInformation
            {
                Name = info.Name
            };

            ItemTemplates = _container.GetInstance <LazyTemplateManager <ItemTemplate> >();

            foreach (var clientOptions in options.InteropClientOptions)
            {
                var client = new Client <CenterServerSocket>(
                    clientOptions,
                    _container.GetInstance <CenterServerSocketFactory>()
                    );

                InteropClients.Add(client);
                await client.Run();

                Logger.Info($"Connected to interoperability server on {client.Channel.RemoteAddress}");
            }

            GameServer = new Server <LoginClientSocket>(
                options.GameServerOptions,
                _container.GetInstance <LoginClientSocketFactory>()
                );

            await GameServer.Run();

            Logger.Info($"Bounded {LoginInformation.Name} on {GameServer.Channel.LocalAddress}");

            InteropClients.ForEach(c =>
            {
                using (var p = new OutPacket(InteropRecvOperations.ServerRegister))
                {
                    p.Encode <byte>((byte)ServerType.Login);
                    LoginInformation.Encode(p);

                    c.Socket.SendPacket(p);
                }
            });
        }