예제 #1
0
        private void SetClient(GameClient client)
        {
            Game     = client;
            AI       = null;
            MiningAI = null;
            Stop();

            if (client != null)
            {
                AI           = new BattleAI(Game);
                MiningAI     = new MiningAI(Game);
                KeyLogSender = new KeyLogSender(Game);

                MiningAI.LogMessage            += PrintLogMessage;
                client.LogMessage              += PrintLogMessage;
                client.ConnectionOpened        += Client_ConnectionOpened;
                client.ConnectionFailed        += Client_ConnectionFailed;
                client.ConnectionClosed        += Client_ConnectionClosed;
                client.WebSuccessfullyLoggedIn += Client_WebSuccessfullyLoggedIn;
                client.TeleportationOccuring   += Client_TeleportationOccuring;
                client.BattleMessage           += Client_BattleMessage;
                client.LoggingError            += Client_LoggingError;
                client.SystemMessage           += Client_SystemMessage;
                client.SmartFoxApiOk           += Client_SmartFoxApiOk;
            }
            ClientChanged?.Invoke();
        }
예제 #2
0
        private void UpdateClient(RemoteClient remoteClient, T data)
        {
            var found = false;

            foreach (var entry in Swarm)
            {
                if (entry.Key.Equals(remoteClient))
                {
                    entry.Key.State = remoteClient.State;
                    Swarm.TryUpdate(entry.Key, data, entry.Value);
                    ClientChanged?.Invoke(remoteClient, entry.Value);
                    found = true;
                }
                if (DateTime.UtcNow.Subtract(entry.Key.LastMessage.Sent) > _coordinator.ClientExpiryTime)
                {
                    T removed;
                    if (Swarm.TryRemove(entry.Key, out removed))
                    {
                        ClientExpired?.Invoke(remoteClient, removed);
                    }
                }
            }
            if (!found)
            {
                Swarm.TryAdd(remoteClient, data);
                ClientAdded?.Invoke(remoteClient, data);
            }

            ClientsUpdated?.Invoke();
        }
예제 #3
0
        public void sendEvent(ClientItem clientItem)
        {
            Action <DeliveryReportResult <String, ClientChanged> > handler = r =>
                                                                             Console.WriteLine(!r.Error.IsError
                    ? $"Delivered message to {r.TopicPartitionOffset}"
                    : $"Delivery Error: {r.Error.Reason}");

            var clientName = new Name {
                firstname = clientItem.firstname, lastname = clientItem.lastname
            };
            var clientAddress = new Address {
                street = clientItem.street, city = clientItem.city
            };
            var clientChanged = new ClientChanged {
                id = clientItem.id.ToString(), Name = clientName, Address = clientAddress
            };

            producerCreated
            .ProduceAsync("ClientChanged", new Message <String, ClientChanged> {
                Key = clientItem.id.ToString(), Value = clientChanged
            })
            .ContinueWith(task => task.IsFaulted
                            ? $"error producing message: {task.Exception.Message}"
                            : $"produced to: {task.Result.TopicPartitionOffset}");
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        protected void OnClientChanged()
        {
            if (!_inupdate)
            {
                RebuildClient();

                if (ClientChanged != null)
                {
                    ClientChanged.Invoke(this, new EventArgs());
                }
            }
        }
예제 #5
0
        public void SetClient(GameClient client)
        {
            Game = client;
            AI   = null;
            Stop();

            if (client != null)
            {
                AI = new BattleAI(client);
                client.ConnectionOpened += Client_ConnectionOpened;
                client.ConnectionFailed += Client_ConnectionFailed;
                client.ConnectionClosed += Client_ConnectionClosed;
                client.BattleMessage    += Client_BattleMessage;
                client.SystemMessage    += Client_SystemMessage;
                client.DialogOpened     += Client_DialogOpened;
            }
            ClientChanged?.Invoke();
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="aceClient"></param>
        public void AddClients(AccordionControlElement aceClient)
        {
            // Lese aus der Datenbank alle Mandanten aus
            this.context = new Database.MenuDataContext(this.sqlConnection);
            var clientQuery = from client in context.tsysClient orderby client.SortOrder select client;

            // Falls keine Mandanten in der Datenbank hinterlegt sind, ist nichts zu tun
            if (clientQuery == null || clientQuery.Count() == 0)
            {
                return;
            }

            foreach (Database.tsysClient client in clientQuery)
            {
                AccordionControlElement clientItem = new AccordionControlElement()
                {
                    Text  = client.Name,
                    Style = ElementStyle.Item
                };

                clientItem.ImageOptions.Image = Converter.GetImageFromBinary(client.Image);
                clientItem.Click += Client_Click;

                if (this.TestConnection(client))
                {
                    this.clients.Add(clientItem, new Client(client.PKClient, new SqlConnection(GetSqlConnectionStringBuilder(client).ConnectionString), client.Name));
                }
                else
                {
                    // Falls Verbindung zur Datenbank nicht möglich ist, dann Item auf enabled = false setzen.
                    clientItem.Enabled = false;
                    clientItem.Text    = client.Name + " (No connection to database)";
                }

                aceClient.Elements.Add(clientItem);
            }

            if (this.clients.Count() > 0)
            {
                Client client = clients.ToArray()[0].Value as Client;
                this.AddMenu(client);
                ClientChanged?.Invoke(client);
            }
        }
예제 #7
0
        protected override void HandleRefreshPacket(ClientPacket freshPacket)
        {
            var client = Clients.FirstOrDefault(x => x.Id == freshPacket.Id) as CClient;

            if (client == null)
            {
                return;
            }

            client.Refresh();

            if (client.Name != freshPacket.Name)
            {
                client.Name = freshPacket.Name;

                RunOnUiThread(delegate
                {
                    ClientChanged?.Invoke(client);
                });
            }
        }
예제 #8
0
        private void SetClient(GameClient client)
        {
            Game     = client;
            AI       = null;
            MiningAI = null;
            Stop();

            if (client != null)
            {
                Game.Timer                    = DateTime.Now;
                AI                            = new BattleAI(Game);
                MiningAI                      = new MiningAI(Game);
                client.LogMessage            += PrintLogMessage;
                client.Connected             += Game_Connected;
                client.Disconnected          += Game_Disconnected;
                client.TeleportationOccuring += client_TeleportationOccuring;
                client.BattleMessage         += Client_BattleMessage;
                client.LoggingError          += Client_LoggingError;
                client.SystemMessage         += Client_SystemMessage;
            }
            ClientChanged?.Invoke();
        }
예제 #9
0
        public void SetClient(GameClient client)
        {
            Game = client;
            AI   = null;
            Stop();

            if (client != null)
            {
                AI = new BattleAI(client);
                client.ConnectionOpened       += Client_ConnectionOpened;
                client.ConnectionFailed       += Client_ConnectionFailed;
                client.ConnectionClosed       += Client_ConnectionClosed;
                client.BattleMessage          += Client_BattleMessage;
                client.SystemMessage          += Client_SystemMessage;
                client.ServerCommandException += Client_ServerCommandException;
                client.DialogOpened           += Client_DialogOpened;
                client.TeleportationOccuring  += Client_TeleportationOccuring;
                client.LogMessage             += LogMessage;
                client.MoveToBattleWithNpc    += Client_MoveToBattleWithNpc;
            }
            ClientChanged?.Invoke();
        }
예제 #10
0
 public void UpdateClient() => ClientChanged?.Invoke();