Beispiel #1
0
        public async void ConnectServer(int id, bool status = true)
        {
            var session = new SessionScope
            {
                Name          = id.ToString(),
                ServerAddress = "gs.sunnycase.moe",
                ServerPort    = 25565
            };
            var scope = ServiceProvider.BeginLifetimeScope(c =>
            {
                c.RegisterInstance(session);
            });

            session.ServiceProvider = scope;
            _sessionScopes[id]      = session;
            var clientSession = scope.Resolve <ClientSession>();
            var handler       = status ? (EventHandler)scope.Resolve <StatusFlow>().OnClientSessionConnected : scope.Resolve <LoginFlow>().OnClientSessionConnected;

            clientSession.Connected += handler;
            await clientSession.Startup(default);