예제 #1
0
        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
            }
        }
예제 #2
0
        protected virtual void PortOnPortEndCall(object sender, CallEventArgs e)
        {
            var call = CurrentCalls.FirstOrDefault(x => x.RecieverNumber == e.number || x.SenderNumber == e.number);

            if (call == null)
            {
                return;
            }

            var port1 = CallingPorts.FirstOrDefault(x => x.Number == call.SenderNumber);

            if (port1 == null)
            {
                return;
            }

            var port2 = CallingPorts.FirstOrDefault(x => x.Number == call.RecieverNumber);

            if (port2 == null)
            {
                return;
            }
            call.Finish();
            ServerFinishedCall?.Invoke(this, new ConnectionEventArgs(port1, port2, string.Format($"Call finished. Duration: {call.Duration:hh\\:mm\\:ss}")));
            CallingPorts.Remove(port1);
            CallingPorts.Remove(port2);
            EnabledPorts.Add(port1);
            EnabledPorts.Add(port2);

            CurrentCalls.Remove(call);
            StorageCalls.Add(call);
            CallFinished?.Invoke(call, EventArgs.Empty);
        }
예제 #3
0
 void CallManager_OnCallRemoved(ICall call, CallRemoveReason reason)
 {
     CurrentCalls.Remove(call);
 }