public void JoinUser(string token) { ConnectedUser user = GetSubscriber(token); if (user == null) { logger.Error("Attempted to join user but they are not subbed"); return; } OpParticipant np = new OpParticipant(); np.profile = user.profile; np.position = null; np.isFC = user.profile.id == FCID; roster.Add(np); PushToAll(new ANWI.Messaging.Ops.UpdateRoster( new List <OpParticipant>() { np }, null )); }
public void RemoveUser(int id) { OpParticipant user = GetParticipant(id); if (user == null) { return; } // If the user is currently in a position unassign it if (user.position != null) { string posUUID = user.position.uuid; fleet.ClearPosition(posUUID); PushToAll(new ANWI.Messaging.Ops.UpdateAssignments( null, null, new List <string>() { posUUID } )); } // Remove them from the roster and send update roster.Remove(user); PushToAll(new ANWI.Messaging.Ops.UpdateRoster( null, new List <int>() { user.profile.id } )); }
private void PositionGrid_Drop(object sender, DragEventArgs e) { Grid grid = sender as Grid; OpPosition pos = grid.DataContext as OpPosition; OpParticipant user = (draggedItem.DataContext as OpParticipant); ChangeAssignment(pos, user.profile.id); }
ChangeAssignment(string posUUID, int userID) { if (posUUID == "" && userID != -1) { OpParticipant user = GetParticipant(userID); if (user == null) { return; } // Unassign this user if (user.position != null) { fleet.ClearPosition(user.position.uuid); PushToAll(new ANWI.Messaging.Ops.UpdateAssignments( null, new List <int>() { userID }, null)); } } else if (userID == -1 && posUUID != "") { // Unassign this position fleet.ClearPosition(posUUID); PushToAll(new ANWI.Messaging.Ops.UpdateAssignments( null, null, new List <string>() { posUUID })); } else { OpParticipant user = GetParticipant(userID); if (user == null) { return; } // Assign user to this position fleet.AssignPosition(posUUID, user); PushToAll(new ANWI.Messaging.Ops.UpdateAssignments( new List <System.Tuple <int, string> >() { new System.Tuple <int, string>(userID, posUUID), }, null, null)); } }
/// <summary> /// Opening window and request the operation from the server /// identified by the UUID /// </summary> /// <param name="uuid"></param> public OperationDetails(Profile profile, string uuid) { this.DataContext = this; InitializeComponent(); opUUID = uuid; this.profile = profile; working = true; fleet.assignedPositionAdded += (pos) => { OpParticipant user = GetParticipant(pos.filledById); if (user != null) { pos.filledByPointer = user; user.position = pos; } }; MessageRouter.Instance.SubscribeSource(opUUID, this); AddProcessor(typeof(ANWI.Messaging.Ops.FullOperationSnapshot), ProcessOpSnapshot); AddProcessor(typeof(ANWI.Messaging.Ops.UpdateRoster), ProcessUpdateRoster); AddProcessor(typeof(ANWI.Messaging.Ops.UpdateStatus), ProcessUpdateStatus); AddProcessor(typeof(ANWI.Messaging.Ops.UpdateUnitsShips), ProcessUpdateOOBShips); AddProcessor(typeof(ANWI.Messaging.Ops.UpdateUnitsWings), ProcessUpdateOOBWings); AddProcessor(typeof(ANWI.Messaging.Ops.UpdateUnitsBoats), ProcessUpdateOOBBoats); AddProcessor(typeof(ANWI.Messaging.Ops.UpdateAssignments), ProcessUpdateAssignments); AddProcessor(typeof(ANWI.Messaging.Ops.UpdatePositions), ProcessUpdatePositions); AddProcessor(typeof(ANWI.Messaging.Ops.UpdateShip), ProcessUpdateShip); AddProcessor(typeof(ANWI.Messaging.Ops.UpdateWing), ProcessUpdateWing); AddProcessor(typeof(ANWI.Messaging.Ops.UpdateSettings), ProcessUpdateSettings); RebuildC2(); MessageRouter.Instance.Send( MessageRouter.Service.Ops, new ANWI.Messaging.Request( ANWI.Messaging.Request.Type.GetOperation, new ANWI.Messaging.ReqExp.IdString(0, uuid)), this ); }
private void AddParticipants(List <OpParticipant> add) { foreach (OpParticipant p in add) { // Only add them if they don't already exist in the roster if (GetParticipant(p.profile.id) == null) { if (p.profile.id == userId) { thisUser = p; isFC = thisUser.isFC; NotifyPropertyChanged(string.Empty); } this.Dispatcher.Invoke(() => { roster.Add(p); }); } } NotifyPropertyChanged("currentUserNumber"); }
private void RemoveParticipants(List <int> rem) { foreach (int id in rem) { OpParticipant user = GetParticipant(id); if (user != null) { if (user.profile.id == userId) { thisUser = null; isFC = false; NotifyPropertyChanged(string.Empty); } this.Dispatcher.Invoke(() => { roster.Remove(user); }); } } NotifyPropertyChanged("currentUserNumber"); }
private void ProcessUpdateAssignments(ANWI.Messaging.IMessagePayload p) { ANWI.Messaging.Ops.UpdateAssignments au = p as ANWI.Messaging.Ops.UpdateAssignments; if (au.added != null) { foreach (Tuple <int, string> add in au.added) { OpParticipant member = GetParticipant(add.Item1); if (member != null) { fleet.AssignPosition(add.Item2, member); } } } if (au.removedByUser != null) { foreach (int rem in au.removedByUser) { OpParticipant member = GetParticipant(rem); if (member != null && member.position != null) { fleet.ClearPosition(member.position.uuid); } } } if (au.removedByUUID != null) { foreach (string rem in au.removedByUUID) { fleet.ClearPosition(rem); } } RebuildC2(); NotifyPropertyChanged(string.Empty); }
public User(OpParticipant member) { commander = member.position.role.channelCdr; rank = member.profile.rank.abbrev; name = member.profile.nickname; }