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); }
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); }
public static async Task <RequestData> EndEmergency(string handle) { Player p = Common.GetPlayerByHandle(handle); EmergencyCall call = Common.GetEmergencyCall(handle); // checking for call null if (call == null) { return(new RequestData("civ_911_not_exist", new EventArgument[] { Common.GetPlayerId(p) })); } #if DEBUG Common.SendMessage(p, "", new[] { 0, 0, 0 }, "Ending 911 call..."); #endif // finding the dispatcher ip var dispatcherIp = Server.Calls.ContainsKey(call.Id) ? Server.Calls[call.Id] : null; var peer = Server.ConnectedDispatchers.FirstOrDefault(x => x.RemoteIP == dispatcherIp); // finding the peer from the ip var task = peer?.RemoteCallbacks.Events?["end" + call.Id].Invoke(); // creating the task from the events // removing the call from the calls list CurrentCalls.Remove(call); if (!(task is null)) { await task; // await the task } return(new RequestData(null, new EventArgument[] { Common.GetPlayerId(p) })); }
private async Task <object> AcceptEmergency(ConnectedPeer sender, object[] args) { await Task.FromResult(0); if (CheckAndDispose(sender)) { return(null); } #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Accept emergency Request Received"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Accept emergency Request Received"); #endif Guid id = (Guid)args[0]; EmergencyCall acceptedCall = DispatchSystem.currentCalls.Find(x => x.Id == id); if (Calls.ContainsKey(id) || acceptedCall == null) { return(false); // Checking null and accepted in same expression } Calls.Add(id, sender.RemoteIP); 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); }
private async Task MessageEmergency(ConnectedPeer sender, object[] args) { await Task.FromResult(0); if (CheckAndDispose(sender)) { return; } #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] Message emergency Request Received"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] Message emergency Request Received"); #endif Guid id = (Guid)args[0]; string msg = args[1] as string; EmergencyCall call = DispatchSystem.currentCalls.Find(x => x.Id == id); DispatchSystem.Invoke(() => { Player p = Common.GetPlayerByIp(call?.SourceIP); if (p != null) { Common.SendMessage(p, "Dispatcher", new [] { 0x0, 0xff, 0x0 }, msg); } }); }
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"); } }); } }
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) }); } }); } }
public static async void InitializeEmergency(string handle) { Player p = GetPlayerByHandle(handle); if (GetEmergencyCall(handle) != null) { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You already have a 911 call!"); return; } if (GetCivilian(handle) != null) { Civilian civ = GetCivilian(handle); if (server.ConnectedDispatchers.Length == 0) { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "It seems like there is no connected dispatchers at this moment!"); return; } EmergencyCall call; currentCalls.Add(call = new EmergencyCall(p.Identifiers["ip"], $"{civ.First} {civ.Last}")); SendMessage(p, "Dispatch911", new[] { 255, 0, 0 }, "Please wait for a dispatcher to respond"); foreach (var peer in server.ConnectedDispatchers) { await peer.TriggerNetEvent("911alert", civ, call); } } else { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your name before start a 911 call"); } }
public static async void EndEmergency(string handle) { Player p = GetPlayerByHandle(handle); EmergencyCall call = GetEmergencyCall(handle); // checking for call null if (call == null) { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "There is no 911 call to end!"); return; } #if DEBUG SendMessage(p, "", new[] { 0, 0, 0 }, "Ending 911 call..."); #endif // finding the dispatcher ip string dispatcherIp = Server.Calls.ContainsKey(call.Id) ? Server.Calls[call.Id] : null; ConnectedPeer peer = Server.ConnectedDispatchers.FirstOrDefault(x => x.RemoteIP == dispatcherIp); // finding the peer from the ip var task = peer?.RemoteCallbacks.Events?["end" + call.Id].Invoke(); // creating the task from the events // removing the call from the calls list CurrentCalls.Remove(call); SendMessage(p, "Dispatch911", new[] { 255, 0, 0 }, "Ended the 911 call"); if (!(task is null)) { await task; // await the task } }
public static async void InitializeEmergency(string handle) { Player p = GetPlayerByHandle(handle); // checking for an existing emergency if (GetEmergencyCall(handle) != null) { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You already have a 911 call!"); return; } if (GetCivilian(handle) != null) { Civilian civ = GetCivilian(handle); // finding the civ // checking how many active dispatchers there are if (Server.ConnectedDispatchers.Length == 0) { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "It seems like there is no connected dispatchers at this moment!"); return; } EmergencyCall call; CurrentCalls.Add(call = new EmergencyCall(p.Identifiers["ip"], $"{civ.First} {civ.Last}")); // adding and creating the instance of the emergency SendMessage(p, "Dispatch911", new[] { 255, 0, 0 }, "Please wait for a dispatcher to respond"); // msging to wait for a dispatcher foreach (var peer in Server.ConnectedDispatchers) { await peer.RemoteCallbacks.Events["911alert"].Invoke(civ, call); // notifying the dispatchers of the 911 call } } else { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You must set your name before start a 911 call"); } }
public static void EndEmergency(string handle) { Player p = GetPlayerByHandle(handle); EmergencyCall call = GetEmergencyCall(handle); if (call == null) { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "There is no 911 call to end!"); return; } #if DEBUG SendMessage(p, "", new[] { 0, 0, 0 }, "Ending 911 call..."); #endif string dispatcherIp = server.Calls[call.Id]; ConnectedPeer peer = server.ConnectedDispatchers.First(x => x.RemoteIP == dispatcherIp); #pragma warning disable 4014 peer.TryTriggerNetEvent("end" + call.Id); #pragma warning restore 4014 currentCalls.Remove(call); SendMessage(p, "Dispatch911", new[] { 255, 0, 0 }, "Ended the 911 call"); }
private async Task EndEmergency(ConnectedPeer sender, object[] args) { await Task.FromResult(0); if (CheckAndDispose(sender)) { return; } #if DEBUG Log.WriteLine($"[{sender.RemoteIP}] End emergency Request Received"); #else Log.WriteLineSilent($"[{sender.RemoteIP}] End emergency Request Received"); #endif Guid id = (Guid)args[0]; Calls.Remove(id); EmergencyCall call = DispatchSystem.currentCalls.Find(x => x.Id == id); if (DispatchSystem.currentCalls.Remove(call)) { 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"); } }); } }
private static async Task Alert911(ConnectedPeer peer, Civilian civ, EmergencyCall call) { await Task.FromResult(0); mainWindow.Invoke((MethodInvoker) delegate { new Accept911(civ, call).Show(); }); }
public Symptom(int StageOfGravity, int Duration, string Description, Speciality speciality, EmergencyCall emergencyCall) : this() { this.StageOfGravity = StageOfGravity; this.Duration = Duration; this.Description = Description; addSpeciality(speciality); addEmergencyCall(emergencyCall); }
public Accept911(Civilian requester, EmergencyCall call) { Icon = Icon.ExtractAssociatedIcon("icon.ico"); InitializeComponent(); civ = requester; this.call = call; information.Text = $"Incoming call from {requester.First} {requester.Last} for an UNKNOWN reason..."; SetForegroundWindow(Handle); }
public Task Handle(EmergencyCall message, IMessageHandlerContext context) { var rover = RoverRepository.GetRover( Guid.Parse(EncryptionUtils.Instance.Decrypt(message.EncryptedRoverId))); rover.Lock(); RoverRepository.UpdateRover(rover); return(Task.CompletedTask); }
static void Main(string[] args) { Console.WriteLine("Creating Objects..."); //Relationship Hospital-Speciality Hospital hosp = new Hospital("Av Sur 48", 22.3, 21.4, "La Fe"); Speciality speci = new Speciality("Cardiología"); Deployment dep = new Deployment(3, 24, hosp, speci); hosp.supported_specialities.Add(dep); speci.supportedbyHospital.Add(dep); //Relationship EmergencyCall->Patient Patient pat = new Patient("Camino de Vera s/n", 46, "11111111A", 'H', "Javier", "+34666555444", "Jaen"); EmergencyCall call = new EmergencyCall(new DateTime(2016, 3, 4), 23.5, 22.5, new TimeSpan(12, 12, 45), pat); //Relationship Symptom - Speciality //Relationship Symptom -> EmergencyCall Symptom sy = new Symptom("Taquicardia", 69.5, 3, call, speci); speci.belongs_to.Add(sy); //Relationship EmergencyCall ->Symptom call.symptoms.Add(sy); //Relationship HospitalBased - Hospital Private private_ambulance = new Private("Ambulancias ISW", "full equiped", 23.5, 22.1, 12345); HospitalBased hospital_ambulance = new HospitalBased("full equiped", 20.1, 10.6, 5555, hosp); hosp.owned_ambulances.Add(hospital_ambulance); //Relationship Hospital - EmergencyCall hosp.assigned_calls.Add(call); call.hospital = hosp; //Relationship EmergencyCall - Ambulance call.ambulance = hospital_ambulance; hospital_ambulance.assigned_calls.Add(call); //Relationship EmergencyCallService -> Ambulance //Relationship EmergencyCallService -> Hospital //Relationship EmergencyCallService -> EmergencyCall EmergencyCallService emergencyService = new EmergencyCallService(private_ambulance, hosp); emergencyService.ambulances.Add(hospital_ambulance); emergencyService.calls.Add(call); Console.WriteLine("Objects Created..."); }
public static async void MessageEmergency(string handle, string msg) { Player p = GetPlayerByHandle(handle); EmergencyCall call = GetEmergencyCall(handle); if (call?.Accepted ?? true) // checking if null and if accepted in the same check { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You're call must be answered or started first"); return; } string dispatcherIp = Server.Calls[call.Id]; // getting the dispatcher ip from the calls ConnectedPeer peer = Server.ConnectedDispatchers.First(x => x.RemoteIP == dispatcherIp); // finding the peer from the given IP await peer.RemoteCallbacks.Events[call.Id.ToString()].Invoke(msg); // invoking the remote event for the message in the peer }
public static async void MessageEmergency(string handle, string msg) { Player p = GetPlayerByHandle(handle); EmergencyCall call = GetEmergencyCall(handle); if (call?.Accepted ?? true) { SendMessage(p, "DispatchSystem", new[] { 0, 0, 0 }, "You're call must be answered or started first"); return; } string dispatcherIp = server.Calls[call.Id]; ConnectedPeer peer = server.ConnectedDispatchers.First(x => x.RemoteIP == dispatcherIp); await peer.TryTriggerNetEvent(call.Id.ToString(), msg); }
public static int Main(string[] args) { EmergencyCallService ecs = new EmergencyCallService(); Hospital hospital = new Hospital(); hospital.Name = "9 Octubre"; hospital.Address = "Avenida 9 Octubre"; hospital.Latitude = 39.4; hospital.Longitude = -0.4; ecs.addHospital(hospital); Speciality speciality = new Speciality(); speciality.Name = "Cirujia"; Deployment deployment = new Deployment(hospital, speciality, 1, 15); speciality.addDeployment(deployment); hospital.addDeployment(deployment); Symptom symptom = new Symptom(); symptom.StageOfGravity = 4; symptom.Duration = 5; symptom.Description = "Costillas rotas - Mafia"; symptom.Speciality = speciality; speciality.addSymptom(symptom); Patient patient = new Patient(121241, "Carlos", "Galindo", true, 25, 643328918, "Calle Street"); Ambulance ambulance = new HospitalBased(10931, "Muletas", 40, 0); hospital.addHospitalBased(ambulance); ecs.addAmbulance(ambulance); EmergencyCall emergencyCall = new EmergencyCall(39.4, -0.5, new DateTime(), patient, ambulance, hospital, symptom); symptom.addEmergencyCall(emergencyCall); ambulance.addEmergencyCall(emergencyCall); hospital.addEmergencyCall(emergencyCall); ecs.addEmergencyCall(emergencyCall); PrivateAmbulance privateAmbulance = new PrivateAmbulance(1231513, "Mas muletas", 40, -20, "Company Inc."); return(0); }
public Message911(Civilian civ, EmergencyCall call) { Icon = Icon.ExtractAssociatedIcon("icon.ico"); InitializeComponent(); this.civ = civ; this.call = call; Text += $"{civ.First} {civ.Last}"; Program.Client.Events.Add(call.Id.ToString(), new NetEvent(Msg911)); Program.Client.Events.Add("end" + call.Id, new NetEvent(End911)); Closed += async delegate { await Program.Client.TryTriggerNetEvent("911End", call.Id); Program.Client.Events.Remove("end" + call.Id); Program.Client.Events.Remove(call.Id.ToString()); }; }
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 }); } }); }
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); } }); }
public Message911(Civilian civ, EmergencyCall call) { Icon = Icon.ExtractAssociatedIcon("icon.ico"); InitializeComponent(); SkinManager.AddFormToManage(this); this.civ = civ; this.call = call; Text += $"{civ.First} {civ.Last}"; Program.Client.LocalCallbacks.Events.Add(call.Id.ToString(), new LocalEvent(new Func <ConnectedPeer, string, Task>(Msg911))); Program.Client.LocalCallbacks.Events.Add("end" + call.Id, new LocalEvent(new Func <ConnectedPeer, Task>(End911))); Closed += async delegate { await Program.Client.Peer.RemoteCallbacks.Events["911End"].Invoke(call.Id); Program.Client.LocalCallbacks.Events.Remove("end" + call.Id); Program.Client.LocalCallbacks.Events.Remove(call.Id.ToString()); }; }
public static async Task <RequestData> InitializeEmergency(string handle) { Player p = Common.GetPlayerByHandle(handle); // ReSharper disable once IdentifierTypo var emerCall = Common.GetEmergencyCall(handle); // checking for an existing emergency if (emerCall != null) { return(new RequestData("civ_911_exist", new EventArgument[] { Common.GetPlayerId(p) })); } Civilian civ = Common.GetCivilian(handle); // finding the civ if (civ == null) { return(new RequestData("civ_not_exist", new EventArgument[] { Common.GetPlayerId(p) })); } // checking how many active dispatchers there are if (Server.ConnectedDispatchers.Length == 0) { return(new RequestData("civ_911_no_dispatchers", new EventArgument[] { Common.GetPlayerId(p) })); } emerCall = new EmergencyCall(p.Identifiers["ip"], $"{civ.First} {civ.Last}"); CurrentCalls.Add(emerCall); // adding and creating the instance of the emergency foreach (var peer in Server.ConnectedDispatchers) { await peer.RemoteCallbacks.Events["911alert"] .Invoke(civ, emerCall); // notifying the dispatchers of the 911 call } return(new RequestData(null, new EventArgument[] { Common.GetPlayerId(p) })); }
public void addEmergencyCall(EmergencyCall e);
public EmergencyCallClient(EmergencyCallFactory factory, Patient patient) { _patient = factory.CreatePatient(patient.Symptom, patient.Priority); _emergencyCall = factory.CreateEmergencyCalled(); }
public EmergencyCall GetEmergencyCall() { MyEmergencyCall = new EmergencyCall(); return(MyEmergencyCall); }
public void pushCall(EmergencyCall emergencycall) { }
public void removeEmergencyCall(EmergencyCall e);