Example #1
1
		private void internalEventHandler(object sender, ManagerEvent e)
		{
			int eventHash = e.GetType().Name.GetHashCode();
			if (registeredEventHandlers.ContainsKey(eventHash))
			{
				switch (registeredEventHandlers[eventHash])
				{
					#region A-C
					case 0:
						if (AgentCallbackLogin != null)
						{
							AgentCallbackLogin(this, (AgentCallbackLoginEvent)e);
							return;
						}
						break;
					case 1:
						if (AgentCallbackLogoff != null)
						{
							AgentCallbackLogoff(this, (AgentCallbackLogoffEvent)e);
							return;
						}
						break;
					case 2:
						if (AgentCalled != null)
						{
							AgentCalled(this, (Event.AgentCalledEvent)e);
							return;
						}
						break;
					case 3:
						if (AgentComplete != null)
						{
							AgentComplete(this, (Event.AgentCompleteEvent)e);
							return;
						}
						break;
					case 4:
						if (AgentConnect != null)
						{
							AgentConnect(this, (Event.AgentConnectEvent)e);
							return;
						}
						break;
					case 5:
						if (AgentDump != null)
						{
							AgentDump(this, (Event.AgentDumpEvent)e);
							return;
						}
						break;
					case 6:
						if (AgentLogin != null)
						{
							AgentLogin(this, (Event.AgentLoginEvent)e);
							return;
						}
						break;
					case 7:
						if (AgentLogoff != null)
						{
							AgentLogoff(this, (Event.AgentLogoffEvent)e);
							return;
						}
						break;
					case 8:
						if (AgentsComplete != null)
						{
							AgentsComplete(this, (AgentsCompleteEvent)e);
							return;
						}
						break;
					case 9:
						if (Agents != null)
						{
							Agents(this, (AgentsEvent)e);
							return;
						}
						break;
					case 10:
						if (AlarmClear != null)
						{
							AlarmClear(this, (AlarmClearEvent)e);
							return;
						}
						break;
					case 11:
						if (Alarm != null)
						{
							Alarm(this, (AlarmEvent)e);
							return;
						}
						break;
					case 12:
						if (Cdr != null)
						{
							Cdr(this, (CdrEvent)e);
							return;
						}
						break;
					#endregion
					#region D-L
					case 14:
						if (DBGetResponse != null)
						{
							DBGetResponse(this, (DBGetResponseEvent)e);
							return;
						}
						break;
					case 15:
						if (Dial != null)
						{
							Dial(this, (DialEvent)e);
							return;
						}
						break;
					case 17:
						if (DNDState != null)
						{
							DNDState(this, (DNDStateEvent)e);
							return;
						}
						break;
					case 18:
						if (ExtensionStatus != null)
						{
							ExtensionStatus(this, (ExtensionStatusEvent)e);
							return;
						}
						break;
					case 19:
						if (Hangup != null)
						{
							Hangup(this, (HangupEvent)e);
							return;
						}
						break;
					case 20:
						if (HoldedCall != null)
						{
							HoldedCall(this, (HoldedCallEvent)e);
							return;
						}
						break;
					case 21:
						if (Hold != null)
						{
							Hold(this, (HoldEvent)e);
							return;
						}
						break;
					case 22:
						if (Join != null)
						{
							Join(this, (JoinEvent)e);
							return;
						}
						break;
					case 23:
						if (Leave != null)
						{
							Leave(this, (LeaveEvent)e);
							return;
						}
						break;
					case 24:
						if (Link != null)
						{
							Link(this, (LinkEvent)e);
							return;
						}
						break;
					case 25:
						if (LogChannel != null)
						{
							LogChannel(this, (LogChannelEvent)e);
							return;
						}
						break;
					#endregion
					#region M-P
					case 26:
						if (MeetMeJoin != null)
						{
							MeetMeJoin(this, (MeetmeJoinEvent)e);
							return;
						}
						break;
					case 27:
						if (MeetMeLeave != null)
						{
							MeetMeLeave(this, (MeetmeLeaveEvent)e);
							return;
						}
						break;
					case 28:
						if (MeetMeTalking != null)
						{
							MeetMeTalking(this, (MeetmeTalkingEvent)e);
							return;
						}
						break;
					case 29:
						if (MessageWaiting != null)
						{
							MessageWaiting(this, (MessageWaitingEvent)e);
							return;
						}
						break;
					case 30:
						if (NewCallerId != null)
						{
							NewCallerId(this, (NewCallerIdEvent)e);
							return;
						}
						break;
					case 31:
						if (NewChannel != null)
						{
							NewChannel(this, (NewChannelEvent)e);
							return;
						}
						break;
					case 32:
						if (NewExten != null)
						{
							NewExten(this, (NewExtenEvent)e);
							return;
						}
						break;
					case 33:
						if (NewState != null)
						{
							NewState(this, (NewStateEvent)e);
							return;
						}
						break;
					case 34:
						if (OriginateResponse != null)
						{
							OriginateResponse(this, (OriginateResponseEvent)e);
							return;
						}
						break;
					case 35:
						if (ParkedCall != null)
						{
							ParkedCall(this, (ParkedCallEvent)e);
							return;
						}
						break;
					case 36:
						if (ParkedCallGiveUp != null)
						{
							ParkedCallGiveUp(this, (ParkedCallGiveUpEvent)e);
							return;
						}
						break;
					case 37:
						if (ParkedCallsComplete != null)
						{
							ParkedCallsComplete(this, (ParkedCallsCompleteEvent)e);
							return;
						}
						break;
					case 38:
						if (ParkedCallTimeOut != null)
						{
							ParkedCallTimeOut(this, (ParkedCallTimeOutEvent)e);
							return;
						}
						break;
					case 39:
						if (PeerEntry != null)
						{
							PeerEntry(this, (PeerEntryEvent)e);
							return;
						}
						break;
					case 40:
						if (PeerlistComplete != null)
						{
							PeerlistComplete(this, (PeerlistCompleteEvent)e);
							return;
						}
						break;
					case 41:
						if (PeerStatus != null)
						{
							PeerStatus(this, (PeerStatusEvent)e);
							return;
						}
						break;
					#endregion
					#region Q-Z
					case 42:
						if (QueueEntry != null)
						{
							QueueEntry(this, (QueueEntryEvent)e);
							return;
						}
						break;
					case 43:
						if (QueueMemberAdded != null)
						{
							QueueMemberAdded(this, (QueueMemberAddedEvent)e);
							return;
						}
						break;
					case 44:
						if (QueueMember != null)
						{
							QueueMember(this, (QueueMemberEvent)e);
							return;
						}
						break;
					case 45:
						if (QueueMemberPaused != null)
						{
							QueueMemberPaused(this, (QueueMemberPausedEvent)e);
							return;
						}
						break;
					case 46:
						if (QueueMemberRemoved != null)
						{
							QueueMemberRemoved(this, (QueueMemberRemovedEvent)e);
							return;
						}
						break;
					case 47:
						if (QueueMemberStatus != null)
						{
							QueueMemberStatus(this, (QueueMemberStatusEvent)e);
							return;
						}
						break;
					case 48:
						if (QueueParams != null)
						{
							QueueParams(this, (QueueParamsEvent)e);
							return;
						}
						break;
					case 49:
						if (QueueStatusComplete != null)
						{
							QueueStatusComplete(this, (QueueStatusCompleteEvent)e);
							return;
						}
						break;
					case 50:
						if (Registry != null)
						{
							Registry(this, (RegistryEvent)e);
							return;
						}
						break;
					case 51:
						if (QueueCallerAbandon != null)
						{
							QueueCallerAbandon(this, (QueueCallerAbandonEvent)e);
							return;
						}
						break;
					case 52:
						if (Rename != null)
						{
							Rename(this, (RenameEvent)e);
							return;
						}
						break;
					case 54:
						if (StatusComplete != null)
						{
							StatusComplete(this, (StatusCompleteEvent)e);
							return;
						}
						break;
					case 55:
						if (Status != null)
						{
							Status(this, (StatusEvent)e);
							return;
						}
						break;
					case 56:
						if (Unhold != null)
						{
							Unhold(this, (UnholdEvent)e);
							return;
						}
						break;
					case 57:
						if (Unlink != null)
						{
							Unlink(this, (UnlinkEvent)e);
							return;
						}
						break;
					case 58:
						if (UnparkedCall != null)
						{
							UnparkedCall(this, (UnparkedCallEvent)e);
							return;
						}
						break;
					case 59:
						if (UserEvents != null)
						{
							UserEvents(this, (UserEvent)e);
							return;
						}
						break;
					case 60:
						if (ZapShowChannelsComplete != null)
						{
							ZapShowChannelsComplete(this, (ZapShowChannelsCompleteEvent)e);
							return;
						}
						break;
					case 61:
						if (ZapShowChannels != null)
						{
							ZapShowChannels(this, (ZapShowChannelsEvent)e);
							return;
						}
						break;
					#endregion

					case 62:
						if (Connect != null)
			                        {
			                            Connect(this, (ConnectEvent)e);
			                            return;
			
			                        }
			                        else if (Disconnect != null)
			                        {
			                            Disconnect(this, (DisconnectEvent)e);
			                            return;
			
			                        }
			                        else if (Reload != null)
			                        {
			                            Reload(this, (ReloadEvent)e);
			                            return;
			
			                        }
			                        else if (Shutdown != null)
			                        {
			                            Shutdown(this, (ShutdownEvent)e);
			                            return;
			                        }
						break;
					case 63:
						if (Bridge != null)
						{
							Bridge(this, (BridgeEvent)e);
						}
						break;
					case 64:
						if (Transfer != null)
						{
							Transfer(this, (TransferEvent)e);
						}
						break;
					case 65:
						if (DTMF != null)
						{
							DTMF(this, (DTMFEvent)e);
						}
						break;
					case 70:
						if (VarSet != null)
						{
							VarSet(this, (VarSetEvent)e);
						}
						break;
					case 80:
						if (AGIExec != null)
						{
							AGIExec(this, (AGIExecEvent)e);
						}
						break;
					case 81:
						if (ConfbridgeStart != null)
						{
							ConfbridgeStart(this, (ConfbridgeStartEvent)e);
						}
						break;
					case 82:
						if (ConfbridgeJoin != null)
						{
							ConfbridgeJoin(this, (ConfbridgeJoinEvent)e);
						}
						break;
					case 83:
						if (ConfbridgeLeave != null)
						{
							ConfbridgeLeave(this, (ConfbridgeLeaveEvent)e);
						}
						break;
					case 84:
						if (ConfbridgeEnd != null)
						{
							ConfbridgeEnd(this, (ConfbridgeEndEvent)e);
						}
						break;
					case 85:
						if (ConfbridgeTalking != null)
						{
							ConfbridgeTalking(this, (ConfbridgeTalkingEvent)e);
						}
						break;
                    case 86:
                        if (FailedACL != null)
                        {
                            FailedACL(this, (FailedACLEvent)e);
                        }
                        break;
                    case 87:
				        if (AttendedTransfer != null)
				        {
				            AttendedTransfer(this, (AttendedTransferEvent) e);
				        }
				        break;
                    case 88:
				        if (BridgeCreate != null)
				        {
				            BridgeCreate(this, (BridgeCreateEvent) e);
				        }
				        break;
                    case 89:
                        if (BridgeDestroy != null)
                        {
                            BridgeDestroy(this, (BridgeDestroyEvent)e);
                        }
                        break;
                    case 90:
                        if (BridgeEnter != null)
                        {
                            BridgeEnter(this, (BridgeEnterEvent)e);
                        }
                        break;
                    case 91:
                        if (BridgeLeave != null)
                        {
                            BridgeLeave(this, (BridgeLeaveEvent)e);
                        }
                        break;
                    case 92:
                        if (BlindTransfer != null)
                        {
                            BlindTransfer(this, (BlindTransferEvent)e);
                        }
                        break;
					default:
						if (UnhandledEvent != null)
							UnhandledEvent(this, e);
						return;
				}
			}
			if (fireAllEvents && UnhandledEvent != null)
				UnhandledEvent(this, e);
		}
Example #2
1
		void manager_Events(object sender, ManagerEvent e)
		{
			Debug.WriteLine("Event : " + e.GetType().Name);
		}
        public void HandleEvent(ManagerEvent e)
        {
            // should always be a ResponseEvent, anyway...
            if (e is ResponseEvent)
            {
                var responseEvent = (ResponseEvent) e;
                events.AddEvent(responseEvent);
            }

            // finished?
            if (action.ActionCompleteEventClass().IsAssignableFrom(e.GetType()))
            {
                lock (events)
                    events.Complete = true;
                if (events.Response != null)
                    autoEvent.Set();
            }
        }