public void Login()
        {
            var login = _serverQueryClient.Login(QueryUserName, QueryPassword).Result;

            Console.WriteLine("login {0} {1} {2}", login.Success, login.ErrorId, login.ErrorMessage);

            ServerQueryBaseResult use = _serverQueryClient.Use(UseServerBy.ServerId, 1).Result;

            Console.WriteLine("use {0} {1} {2}", use.Success, use.ErrorId, use.ErrorMessage);

            _serverQueryClient.KeepAlive(TimeSpan.FromMinutes(2));

            var registerTextChannel = _serverQueryClient.ServerNotifyRegister(Event.server).Result;

            Console.WriteLine("registerTextChannel {0} {1} {2}", registerTextChannel.Success, registerTextChannel.ErrorId, registerTextChannel.ErrorMessage);

            _serverQueryClient.NotifyServerEdited += (sender, result) =>
            {
                Console.WriteLine("HOAL!");
            };

            var clientList = _serverQueryClient.ClientList().Result;

            Console.WriteLine("clientList {0} {1} [x{2}]", clientList.Success, clientList.ErrorId, clientList.Values?.Count ?? 0);
        }
Exemple #2
0
        public static void ConnectQueryAsync()
        {
            ServerQueryClient client = new ServerQueryClient(host, port, TimeSpan.FromSeconds(1));

            ServerQueryBaseResult connected = client.Initialize().Result;

            if (connected.Success)
            {
                MessageBox.Show("connected");
            }

            ServerQueryBaseResult login = client.Login(user, password).Result;

            if (!login.Success)
            {
                MessageBox.Show(login.ErrorMessage);
            }

            ServerQueryBaseResult use = client.Use(UseServerBy.Port, 10677).Result;

            if (!use.Success)
            {
                MessageBox.Show(use.ErrorMessage);
            }

            //client.SendTextMessage(TextMessageTargetMode.TextMessageTarget_CLIENT, 3, "please respond");

            ClientListResult clientList = client.ClientList().Result;

            if (!clientList.Success)
            {
                MessageBox.Show(clientList.ErrorMessage);
            }

            client.NotifyTextMessage += (source, notification) => MessageBox.Show(notification.Invokername + ": " + notification.Msg);

            ServerQueryBaseResult registerTextChannel = client.ServerNotifyRegister(Event.textprivate).Result;

            if (!registerTextChannel.Success)
            {
                MessageBox.Show(registerTextChannel.ErrorMessage);
            }

            client.KeepAlive(TimeSpan.FromMinutes(10));
            client.NotifyChannelEdited += (source, notification) => MessageBox.Show(notification.Invokername + ": " + notification.Invokerid);



            for (int i = 0; i < clientList.Values.Count; i++)
            {
                ClientInfoResult clientInfoResult = clientList.Values[i];
                int    id   = clientInfoResult.ClientId;
                String name = clientInfoResult.ClientNickname;

                if (!name.Contains("Sharix"))
                {
                    client.SendTextMessage(TextMessageTargetMode.TextMessageTarget_CLIENT, id, "you are a nonce lol");
                    MessageBox.Show(id.ToString() + " " + name);
                }
            }
        }