コード例 #1
0
        private void ServerService_PasswordChanged(object sender, Server server)
        {
            AdminClientRegisterInfo newInfo = new AdminClientRegisterInfo(server, adminPortClientFactory.Create(new ServerInfo(
                                                                                                                    server.ServerIp, server.ServerPort, server.ServerPassword)));

            newInfo.Client.EventReceived += this.Client_EventReceived;

            this.RegisterInfo.AddOrUpdate(server.GetUniqueKey(),
                                          (_) => newInfo, (_, old) =>
            {
                old.Client.EventReceived -= this.Client_EventReceived;
                foreach (var user in old.GetRegisteredUsers())
                {
                    newInfo.AddUser(user);
                }

                return(newInfo);
            });
        }
コード例 #2
0
        public async Task Register(IAdminPortClientUser owner, Server server)
        {
            AdminClientRegisterInfo info = RegisterInfo.GetOrAdd(server.GetUniqueKey(), (_) =>
            {
                IAdminPortClient client = this.adminPortClientFactory.Create(
                    new ServerInfo(server.ServerIp, server.ServerPort, server.ServerPassword)
                    );

                client.EventReceived += Client_EventReceived;

                return(new AdminClientRegisterInfo(server, client));
            });

            if (info.Client.ConnectionState == AdminConnectionState.Idle)
            {
                await info.Client.Join();
            }

            info.AddUser(owner);
        }