internal static void OnClientIdentified(object sender, JamServer.IdentifiedConnectionEventArgs e) { Console.WriteLine("Client: {0} identified as: {1} - {2}.", e.RemoteEndPoint, e.Account.AccountID, e.Account.Username); AccountOnlineStatusChangedImperative imperative = new AccountOnlineStatusChangedImperative(e.Account, true, e.ServerConnection.Serializer); JamPacket imperativePacket = new JamPacket(Guid.Empty, Guid.Empty, AccountOnlineStatusChangedImperative.DATA_TYPE, imperative.GetBytes()); foreach (JamServerConnection connection in e.ServerConnection.Server.GetAllConnections()) { connection.Send(imperativePacket); } }
public void HandleAccountOnlineStatusChangedImperative(JamPacket packet) { if (packet.Header.DataType != AccountOnlineStatusChangedImperative.DATA_TYPE) { return; } App.Current.Dispatcher.Invoke(() => { MainWindow main = App.Current.MainWindow as MainWindow; AccountOnlineStatusChangedImperative imperative = new AccountOnlineStatusChangedImperative(packet.Data, main.Client.Serializer); if (imperative.Account == null) { return; } Guid selectedAccountID = Guid.Empty; if (selectedAccount != null) { selectedAccountID = SelectedAccount.Account.AccountID; DisplayableAccount account = Accounts.Single(x => x.Account.AccountID == imperative.Account.AccountID); Accounts.Remove(account); account.Online = imperative.Online; Accounts.Add(account); if (selectedAccountID == account.Account.AccountID) { SelectedAccount = account; } NotifyPropertyChanged(nameof(CanSendMessage)); } }); }