Ejemplo n.º 1
0
        private bool AcceptEmergency(ConnectedPeer sender, BareGuid id)
        {
#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Accept emergency Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Accept emergency Request Received");
#endif

            // finding the call in the current calls
            EmergencyCall acceptedCall = DispatchSystem.CurrentCalls.FirstOrDefault(x => x.Id == id);
            if (Calls.ContainsKey(id) || acceptedCall == null)
            {
                return(false);              // Checking null and accepted in same expression
            }
            Calls.Add(id, sender.RemoteIP); // adding the call and dispatcher to the call list
            // setting a message for invocation on the main thread
            DispatchSystem.Invoke(delegate
            {
                Player p = Common.GetPlayerByIp(acceptedCall.SourceIP);
                if (p != null)
                {
                    Common.SendMessage(p, "Dispatch911", new [] { 255, 0, 0 }, "Your 911 call has been accepted by a Dispatcher");
                }
            });
            return(true);
        }
Ejemplo n.º 2
0
 public EmergencyCall(string ip, string playerName)
 {
     Id         = BareGuid.NewBareGuid();
     SourceIP   = ip;
     Creation   = DateTime.Now;
     PlayerName = playerName;
 }
Ejemplo n.º 3
0
        private async Task RemoveOfcAssignment(ConnectedPeer sender, BareGuid ofcId)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Remove officer assignment Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Remove officer assignment Request Received");
#endif

            // finding the ofc
            Officer ofc = global::DispatchSystem.Server.Main.Core.Officers.FirstOrDefault(x => x.Id == ofcId);
            if (ofc == null)
            {
                return;
            }

            if (!global::DispatchSystem.Server.Main.Core.OfficerAssignments.ContainsKey(ofc))
            {
                return;
            }
            global::DispatchSystem.Server.Main.Core.OfficerAssignments.Remove(ofc); // removing the assignment from the officer

            ofc.Status = OfficerStatus.OnDuty;                                      // set on duty

            global::DispatchSystem.Server.Main.DispatchSystem.Invoke(() =>
            {
                Player p = Common.GetPlayerByLic(ofc.License);
                if (p != null)
                {
                    global::DispatchSystem.Server.Main.Core.RequestHandler.TriggerEvent("leo_assignment_removed", new EventArgument[] { Common.GetPlayerId(p) });
                }
            });
        }
Ejemplo n.º 4
0
        private async Task EndEmergency(ConnectedPeer sender, BareGuid id)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] End emergency Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] End emergency Request Received");
#endif

            Calls.Remove(id);                                                                 // removing the id from the calls

            EmergencyCall call = DispatchSystem.CurrentCalls.FirstOrDefault(x => x.Id == id); // obtaining the call from the civ

            if (DispatchSystem.CurrentCalls.Remove(call))                                     // remove, if successful, then notify
            {
                DispatchSystem.Invoke(delegate
                {
                    Player p = Common.GetPlayerByIp(call?.SourceIP);

                    if (p != null)
                    {
                        Common.SendMessage(p, "Dispatch911", new [] { 255, 0, 0 }, "Your 911 call was ended by a Dispatcher");
                    }
                });
            }
        }
Ejemplo n.º 5
0
        private bool AcceptEmergency(ConnectedPeer sender, BareGuid id)
        {
#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Accept emergency Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Accept emergency Request Received");
#endif

            // finding the call in the current calls
            EmergencyCall acceptedCall = global::DispatchSystem.Server.Main.Core.CurrentCalls.FirstOrDefault(x => x.Id == id);
            if (Calls.ContainsKey(id) || acceptedCall == null)
            {
                return(false);              // Checking null and accepted in same expression
            }
            Calls.Add(id, sender.RemoteIP); // adding the call and dispatcher to the call list
            // setting a message for invocation on the main thread
            global::DispatchSystem.Server.Main.DispatchSystem.Invoke(delegate
            {
                Player p = Common.GetPlayerByLic(acceptedCall.License);
                if (p != null)
                {
                    global::DispatchSystem.Server.Main.Core.RequestHandler.TriggerEvent("civ_911_accepted", new EventArgument[] { Common.GetPlayerId(p) });
                }
            });
            return(true);
        }
Ejemplo n.º 6
0
        private async Task AddNote(ConnectedPeer sender, BareGuid id, string note)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Add Civilian note Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Add Civilian note Request Received");
#endif

            Civilian civ = DispatchSystem.Civs.FirstOrDefault(x => x.Id == id); // finding the civ from the id

            if (civ != null)
            {
#if DEBUG
                Log.WriteLine($"[{sender.RemoteIP}] Adding the note \"{note}\" to Civilian {civ.First} {civ.Last}");
#else
                Log.WriteLineSilent($"[{sender.RemoteIP}] Adding the note \"{note}\" to Civilian {civ.First} {civ.Last}");
#endif
                civ.Notes.Add(note); // adding the note for the civilian
            }
            else
#if DEBUG
            { Log.WriteLine($"[{sender.RemoteIP}] Civilian not found, not adding note..."); }
#else
            { Log.WriteLineSilent($"[{sender.RemoteIP}] Civilian not found, not adding note..."); }
#endif
        }
Ejemplo n.º 7
0
        private async Task EndEmergency(ConnectedPeer sender, BareGuid id)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] End emergency Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] End emergency Request Received");
#endif

            Calls.Remove(id);                                                                                          // removing the id from the calls

            EmergencyCall call = global::DispatchSystem.Server.Main.Core.CurrentCalls.FirstOrDefault(x => x.Id == id); // obtaining the call from the civ

            if (global::DispatchSystem.Server.Main.Core.CurrentCalls.Remove(call))                                     // remove, if successful, then notify
            {
                global::DispatchSystem.Server.Main.DispatchSystem.Invoke(delegate
                {
                    Player p = Common.GetPlayerByIp(call?.License);

                    if (p != null)
                    {
                        global::DispatchSystem.Server.Main.Core.RequestHandler.TriggerEvent("civ_911_ended", new EventArgument[] { Common.GetPlayerId(p) });
                    }
                });
            }
        }
Ejemplo n.º 8
0
        private async Task RemoveOfcAssignment(ConnectedPeer sender, BareGuid ofcId)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Remove officer assignment Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Remove officer assignment Request Received");
#endif

            // finding the ofc
            Officer ofc = DispatchSystem.Officers.FirstOrDefault(x => x.Id == ofcId);
            if (ofc == null)
            {
                return;
            }

            if (!DispatchSystem.OfcAssignments.ContainsKey(ofc))
            {
                return;
            }
            DispatchSystem.OfcAssignments.Remove(ofc); // removing the assignment from the officer

            ofc.Status = OfficerStatus.OnDuty;         // set on duty

            DispatchSystem.Invoke(() =>
            {
                Player p = Common.GetPlayerByIp(ofc.SourceIP);
                if (p != null)
                {
                    Common.SendMessage(p, "^8DispatchCAD", new[] { 0, 0, 0 }, "Your assignment has been removed by a dispatcher");
                }
            });
        }
Ejemplo n.º 9
0
        private async Task AddOfcAssignment(ConnectedPeer sender, BareGuid id, BareGuid ofcId)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Add officer assignment Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Add officer assignment Request Received");
#endif

            Assignment assignment = DispatchSystem.Assignments.FirstOrDefault(x => x.Id == id); // finding assignment from the id
            Officer    ofc        = DispatchSystem.Officers.ToList().Find(x => x.Id == ofcId);  // finding the officer from the id
            if (assignment is null || ofc is null)                                              // returning if either is null
            {
                return;
            }
            if (DispatchSystem.OfcAssignments.ContainsKey(ofc)) // returning if the officer already contains the assignment
            {
                return;
            }

            DispatchSystem.OfcAssignments.Add(ofc, assignment); // adding the assignment to the officer

            ofc.Status = OfficerStatus.OffDuty;

            // notify of assignment
            DispatchSystem.Invoke(() =>
            {
                Player p = Common.GetPlayerByIp(ofc.SourceIP);
                if (p != null)
                {
                    Common.SendMessage(p, "^8DispatchCAD", new[] { 0, 0, 0 }, $"New assignment added: \"{assignment.Summary}\"");
                }
            });
        }
Ejemplo n.º 10
0
 public EmergencyCall(string lic, string playerName)
 {
     Id         = BareGuid.NewBareGuid();
     License    = lic;
     Creation   = DateTime.Now;
     PlayerName = playerName;
 }
Ejemplo n.º 11
0
        public PlayerBase(string ip)
        {
            Creation = DateTime.Now;
            Id       = BareGuid.NewBareGuid();

            SourceIP = string.IsNullOrWhiteSpace(ip) ? string.Empty : ip;
        }
Ejemplo n.º 12
0
        public Ticket(string reason, float amount)
        {
            Reason = reason;
            Amount = amount;

            Creation = DateTime.Now;
            Id       = BareGuid.NewBareGuid();
        }
Ejemplo n.º 13
0
 public Bolo(string playerName, string createrIp, string reason)
 {
     _player   = playerName;
     SourceIP  = string.IsNullOrWhiteSpace(createrIp) ? string.Empty : createrIp;
     _reason   = reason;
     _creation = DateTime.Now;
     Id        = BareGuid.NewBareGuid();
 }
Ejemplo n.º 14
0
        private Officer GetOfficer(ConnectedPeer sender, BareGuid id)
        {
#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Get officer Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Get officer Request Received");
#endif

            // finding the officer from the list
            Officer ofc = DispatchSystem.Officers.ToList().Find(x => x.Id == id);
            return(ofc);
        }
Ejemplo n.º 15
0
        private async Task RemoveAssignment(ConnectedPeer sender, BareGuid id)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Remove assignment Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Remove assignment Request Received");
#endif

            Assignment item2 = DispatchSystem.Assignments.FirstOrDefault(x => x.Id == id); // finding the assignment from the id
            Common.RemoveAllInstancesOfAssignment(item2);                                  // removing using common
        }
Ejemplo n.º 16
0
        private Assignment GetOfcAssignment(ConnectedPeer sender, BareGuid id)
        {
#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Get officer assignments Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Get officer assignments Request Received");
#endif

            // finding the officer in the list
            Officer ofc = DispatchSystem.Officers.ToList().Find(x => x.Id == id);

            // finding assignment in common
            return(Common.GetOfficerAssignment(ofc));
        }
Ejemplo n.º 17
0
        private async Task ChangeOfficerStatus(ConnectedPeer sender, BareGuid id, OfficerStatus status)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Change officer status Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Change officer status Request Received");
#endif

            // finding the officer
            Officer ofc = global::DispatchSystem.Server.Main.Core.Officers.FirstOrDefault(x => x.Id == id);

            if (ofc is null)
            {
                return;              // checking for null
            }
            if (ofc.Status != status)
            {
                ofc.Status = status; // changing the status
#if DEBUG
                Log.WriteLine($"[{sender.RemoteIP}] Setting officer status to " + status);
#else
                Log.WriteLineSilent($"[{sender.RemoteIP}] Setting officer status to " + status);
#endif

                global::DispatchSystem.Server.Main.DispatchSystem.Invoke(() =>
                {
                    Player p = Common.GetPlayerByLic(ofc.License);
                    if (p != null)
                    {
                        global::DispatchSystem.Server.Main.Core.RequestHandler.TriggerEvent("leo_status_change",
                                                                                            new EventArgument[]
                        {
                            Common.GetPlayerId(p),
                            ofc.Status.GetHashCode()
                        });
                    }
                });
            }
            else
            {
#if DEBUG
                Log.WriteLine($"[{sender.RemoteIP}] Officer status already set to the incoming status");
#else
                Log.WriteLineSilent($"[{sender.RemoteIP}] Officer status already set to the incoming status");
#endif
            }
        }
Ejemplo n.º 18
0
        private async Task ChangeOfficerStatus(ConnectedPeer sender, BareGuid id, OfficerStatus status)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Change officer status Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Change officer status Request Received");
#endif

            // finding the officer
            Officer ofc = DispatchSystem.Officers.FirstOrDefault(x => x.Id == id);

            if (ofc is null)
            {
                return;              // checking for null
            }
            if (ofc.Status != status)
            {
                ofc.Status = status; // changing the status
#if DEBUG
                Log.WriteLine($"[{sender.RemoteIP}] Setting officer status to " + status);
#else
                Log.WriteLineSilent($"[{sender.RemoteIP}] Setting officer status to " + status);
#endif

                DispatchSystem.Invoke(() =>
                {
                    Player p = Common.GetPlayerByIp(ofc.SourceIP);
                    if (p != null)
                    {
                        Common.SendMessage(p, "^8DispatchCAD", new[] { 0, 0, 0 },
                                           $"Dispatcher set status to {(ofc.Status == OfficerStatus.OffDuty ? "Off Duty" : ofc.Status == OfficerStatus.OnDuty ? "On Duty" : "Busy")}");
                    }
                });
            }
            else
            {
#if DEBUG
                Log.WriteLine($"[{sender.RemoteIP}] Officer status already set to the incoming status");
#else
                Log.WriteLineSilent($"[{sender.RemoteIP}] Officer status already set to the incoming status");
#endif
            }
        }
Ejemplo n.º 19
0
        private async Task RemoveOfficer(ConnectedPeer sender, BareGuid id)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Remove officer Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Add bolo Request Received");
#endif

            // getting the officer
            Officer ofc = DispatchSystem.Officers.FirstOrDefault(x => x.Id == id);
            if (ofc != null)
            {
                // notify of removing of role
                DispatchSystem.Invoke(delegate
                {
                    Player p = Common.GetPlayerByIp(ofc.SourceIP);

                    if (p != null)
                    {
                        Common.SendMessage(p, "^8DispatchCAD", new[] { 0, 0, 0 }, "You have been removed from your officer role by a dispatcher");
                    }
                });

                // actually remove the officer from the list
                DispatchSystem.Officers.Remove(ofc);

#if DEBUG
                Log.WriteLine($"[{sender.RemoteIP}] Removed the officer from the list of officers");
#else
                Log.WriteLineSilent($"[{sender.RemoteIP}] Removed the officer from the list of officers");
#endif
            }
            else
            {
#if DEBUG
                Log.WriteLine($"[{sender.RemoteIP}] Officer in list not found, not removing");
#else
                Log.WriteLineSilent($"[{sender.RemoteIP}] Officer in list not found, not removing");
#endif
            }
        }
Ejemplo n.º 20
0
        private async Task RemoveOfficer(ConnectedPeer sender, BareGuid id)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Remove officer Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Add bolo Request Received");
#endif

            // getting the officer
            Officer ofc = global::DispatchSystem.Server.Main.Core.Officers.FirstOrDefault(x => x.Id == id);
            if (ofc != null)
            {
                // notify of removing of role
                global::DispatchSystem.Server.Main.DispatchSystem.Invoke(delegate
                {
                    Player p = Common.GetPlayerByLic(ofc.License);

                    if (p != null)
                    {
                        global::DispatchSystem.Server.Main.Core.RequestHandler.TriggerEvent("leo_role_removed", new EventArgument[] { Common.GetPlayerId(p) });
                    }
                });

                // actually remove the officer from the list
                global::DispatchSystem.Server.Main.Core.Officers.Remove(ofc);

#if DEBUG
                Log.WriteLine($"[{sender.RemoteIP}] Removed the officer from the list of officers");
#else
                Log.WriteLineSilent($"[{sender.RemoteIP}] Removed the officer from the list of officers");
#endif
            }
            else
            {
#if DEBUG
                Log.WriteLine($"[{sender.RemoteIP}] Officer in list not found, not removing");
#else
                Log.WriteLineSilent($"[{sender.RemoteIP}] Officer in list not found, not removing");
#endif
            }
        }
Ejemplo n.º 21
0
        private async Task AddOfcAssignment(ConnectedPeer sender, BareGuid id, BareGuid ofcId)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Add officer assignment Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Add officer assignment Request Received");
#endif

            Assignment assignment = global::DispatchSystem.Server.Main.Core.Assignments.FirstOrDefault(x => x.Id == id); // finding assignment from the id
            Officer    ofc        = global::DispatchSystem.Server.Main.Core.Officers.ToList().Find(x => x.Id == ofcId);  // finding the officer from the id
            if (assignment is null || ofc is null)                                                                       // returning if either is null
            {
                return;
            }
            if (global::DispatchSystem.Server.Main.Core.OfficerAssignments.ContainsKey(ofc)) // returning if the officer already contains the assignment
            {
                return;
            }

            global::DispatchSystem.Server.Main.Core.OfficerAssignments.Add(ofc, assignment); // adding the assignment to the officer

            ofc.Status = OfficerStatus.OffDuty;

            // notify of assignment
            global::DispatchSystem.Server.Main.DispatchSystem.Invoke(() =>
            {
                Player p = Common.GetPlayerByLic(ofc.License);
                if (p != null)
                {
                    global::DispatchSystem.Server.Main.Core.RequestHandler.TriggerEvent("leo_assignment_added", new EventArgument[]
                    {
                        Common.GetPlayerId(p),
                        assignment.Summary
                    });
                }
            });
        }
Ejemplo n.º 22
0
        private async Task MessageEmergency(ConnectedPeer sender, BareGuid id, string msg)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Message emergency Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Message emergency Request Received");
#endif

            EmergencyCall call = global::DispatchSystem.Server.Main.Core.CurrentCalls.FirstOrDefault(x => x.Id == id); // finding the call

            global::DispatchSystem.Server.Main.DispatchSystem.Invoke(() =>
            {
                Player p = Common.GetPlayerByLic(call?.License); // getting the player from the call's ip

                if (p != null)
                {
                    global::DispatchSystem.Server.Main.Core.RequestHandler.TriggerEvent("civ_911_message", new EventArgument[] { Common.GetPlayerId(p), msg });
                }
            });
        }
Ejemplo n.º 23
0
        private async Task MessageEmergency(ConnectedPeer sender, BareGuid id, string msg)
        {
            await Task.FromResult(0);

#if DEBUG
            Log.WriteLine($"[{sender.RemoteIP}] Message emergency Request Received");
#else
            Log.WriteLineSilent($"[{sender.RemoteIP}] Message emergency Request Received");
#endif

            EmergencyCall call = DispatchSystem.CurrentCalls.FirstOrDefault(x => x.Id == id); // finding the call

            DispatchSystem.Invoke(() =>
            {
                Player p = Common.GetPlayerByIp(call?.SourceIP); // getting the player from the call's ip

                if (p != null)
                {
                    Common.SendMessage(p, "Dispatcher", new [] { 0x0, 0xff, 0x0 }, msg);
                }
            });
        }
Ejemplo n.º 24
0
 public Assignment(string summary)
 {
     Summary  = summary;
     Creation = DateTime.Now;
     Id       = BareGuid.NewBareGuid();
 }