コード例 #1
0
        public void HandleEventThread()
        {
            int iRet, iEventType;
            var evtPtr = new IntPtr();

            JADA.Event evtSelf = null;

            while (true)
            {
                iRet = JADA_ReqGetNextEvent(reqSelf, 15000, ref evtPtr);
                if (iRet == 0)
                {
                    try
                    {
                        evtSelf = new JADA.Event(evtPtr);
                        EventArgs e = new EventArgs(evtSelf);

                        iEventType = evtSelf.EventType;
                        switch (iEventType)
                        {
                        case JADA.Event.EVT_CHATTEXT_RECEIVED:
                            EventHandler ChatTextReceivedHandler = this.ChatTextReceived;
                            if (null != ChatTextReceivedHandler)
                            {
                                ChatTextReceivedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_CALL_OPENED:
                            EventHandler CallOpenedHandler = this.CallOpened;
                            if (null != CallOpenedHandler)
                            {
                                CallOpenedHandler(this, e);
                            }
                            StartAudio();
                            myAudioRestartTimer = new System.Threading.Timer(new TimerCallback(RestartAudioTimer), null, 0, 5 * 60 * 1000);
                            break;

                        case JADA.Event.EVT_CALL_CLOSED:
                            if (myAudioRestartTimer != null)
                            {
                                myAudioRestartTimer.Dispose(); myAudioRestartTimer = null;
                            }
                            StopAudio();
                            EventHandler CallClosedHandler = this.CallClosed;
                            if (null != CallClosedHandler)
                            {
                                CallClosedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_CALL_ABORTED:
                            if (myAudioRestartTimer != null)
                            {
                                myAudioRestartTimer.Dispose(); myAudioRestartTimer = null;
                            }
                            StopAudio();
                            EventHandler CallAbortedHandler = this.CallAborted;
                            if (null != CallAbortedHandler)
                            {
                                CallAbortedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_DESKTOP_OPENED:
                            EventHandler DesktopOpenedHandler = this.DesktopOpened;
                            if (null != DesktopOpenedHandler)
                            {
                                DesktopOpenedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_DESKTOP_REQUESTED:
                            EventHandler DesktopRequestedHandler = this.DesktopRequested;
                            if (null != DesktopRequestedHandler)
                            {
                                DesktopRequestedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_DESKTOP_CLOSED:
                            EventHandler DesktopClosedHandler = this.DesktopClosed;
                            if (null != DesktopClosedHandler)
                            {
                                DesktopClosedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_WHITEBOARD_OPENED:
                            EventHandler WhiteboardOpenedHandler = this.WhiteboardOpened;
                            if (null != WhiteboardOpenedHandler)
                            {
                                WhiteboardOpenedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_WHITEBOARD_CLEANED:
                            EventHandler WhiteboardCleanedHandler = this.WhiteboardCleaned;
                            if (null != WhiteboardCleanedHandler)
                            {
                                WhiteboardCleanedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_WHITEBOARD_CLOSED:
                            EventHandler WhiteboardClosedHandler = this.WhiteboardClosed;
                            if (null != WhiteboardClosedHandler)
                            {
                                WhiteboardClosedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_SET_DRAW_POINTER:
                            EventHandler DrawPointerMovedHandler = this.DrawPointerMoved;
                            if (null != DrawPointerMovedHandler)
                            {
                                DrawPointerMovedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_RESET_DRAW_POINTER:
                            EventHandler DrawPointerResetHandler = this.DrawPointerReset;
                            if (null != DrawPointerResetHandler)
                            {
                                DrawPointerResetHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_PARAMETERS_LIST:
                            EventHandler ParameterListReceivedHandler = this.ParameterListReceived;
                            if (null != ParameterListReceivedHandler)
                            {
                                ParameterListReceivedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_DIRECTORY_LIST:
                            EventHandler DirectoryListReceivedHandler = this.DirectoryListReceived;
                            if (null != DirectoryListReceivedHandler)
                            {
                                DirectoryListReceivedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_PING_REPLY:
                            EventHandler PingReplyHandler = this.PingReply;
                            if (null != PingReplyHandler)
                            {
                                PingReplyHandler(this, e);
                            }
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        JADA.Common.LogMessage(String.Format("HandleEventThread {0}\n{1}", e.Message, e.StackTrace));
                        // MessageBox.Show("Errore nell'applicazione: i dettagli sono stati salvati nel file di log", "AREAS Customer Assistant");
                    }
                    finally
                    {
                        if (evtSelf != null)
                        {
                            evtSelf.Dispose();
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: connection.cs プロジェクト: rleschiera/jada
        //*********************************************************************
        //
        //     G E S T I O N E     E V E N T I
        //
        //*********************************************************************
        public void HandleEventThread()
        {
            int iRet, iEventType;
            var evtPtr = new IntPtr();

            JADA.Event evtSelf = null;

            while (true)
            {
                iRet = JADA_ConnGetNextEvent(connSelf, 15000, ref evtPtr);
                if (iRet == 0)
                {
                    try
                    {
                        evtSelf = new JADA.Event(evtPtr);
                        EventArgs e = new EventArgs(evtSelf);

                        iEventType = evtSelf.EventType;
                        switch (iEventType)
                        {
                        /* Opcode degli eventi: connessione */
                        case JADA.Event.EVT_CONNECTION_CONNECTED:
                            EventHandler ConnectionConnectedHandler = this.ConnectionConnected;
                            if (null != ConnectionConnectedHandler)
                            {
                                ConnectionConnectedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_CONNECTION_OPENED:
                            EventHandler ConnectionOpenedHandler = this.ConnectionOpened;
                            if (null != ConnectionOpenedHandler)
                            {
                                ConnectionOpenedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_CONNECTION_CLOSED:
                            EventHandler ConnectionClosedHandler = this.ConnectionClosed;
                            if (null != ConnectionClosedHandler)
                            {
                                ConnectionClosedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_SESSIONS_LIST:
                            EventHandler SessionListHandler = this.SessionList;
                            if (null != SessionListHandler)
                            {
                                SessionListHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_REQUESTS_LIST:
                            EventHandler RequestsListHandler = this.RequestsList;
                            if (null != RequestsListHandler)
                            {
                                RequestsListHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_LIST_COUNTERS:
                            EventHandler CountersListHandler = this.CountersList;
                            if (null != CountersListHandler)
                            {
                                CountersListHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_PARAMETERS_LIST:
                            EventHandler ParameterListHandler = this.ParameterList;
                            if (null != ParameterListHandler)
                            {
                                ParameterListHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_COMBO_VALUES:
                            EventHandler ComboValuesHandler = this.ComboValues;
                            if (null != ComboValuesHandler)
                            {
                                ComboValuesHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_MSG_RESULT:
                            EventHandler MsgResultHandler = this.MsgResult;
                            if (null != MsgResultHandler)
                            {
                                MsgResultHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_PING_REPLY:
                            EventHandler PingReplyHandler = this.PingReply;
                            if (null != PingReplyHandler)
                            {
                                PingReplyHandler(this, e);
                            }
                            break;

                        /* Opcode degli eventi: supporto */
                        case JADA.Event.EVT_SUPPORT_OPENED:
                            EventHandler SupportOpenedHandler = this.SupportOpened;
                            if (null != SupportOpenedHandler)
                            {
                                SupportOpenedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_SUPPORT_ACCEPTED:
                            EventHandler SupportAcceptedHandler = this.SupportAccepted;
                            if (null != SupportAcceptedHandler)
                            {
                                SupportAcceptedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_SUPPORT_LOADED:
                            EventHandler SupportLoadedHandler = this.SupportLoaded;
                            if (null != SupportLoadedHandler)
                            {
                                SupportLoadedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_SUPPORT_CONNECTED:
                            EventHandler SupportConnectedHandler = this.SupportConnected;
                            if (null != SupportConnectedHandler)
                            {
                                SupportConnectedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_SUPPORT_SOLICITED:
                            EventHandler SupportSolicitedHandler = this.SupportSolicited;
                            if (null != SupportSolicitedHandler)
                            {
                                SupportSolicitedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_SUPPORT_CLOSED:
                            EventHandler SupportClosedHandler = this.SupportClosed;
                            if (null != SupportClosedHandler)
                            {
                                SupportClosedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_SUPPORT_SUSPENDED:
                            EventHandler SupportSuspendedHandler = this.SupportSuspended;
                            if (null != SupportSuspendedHandler)
                            {
                                SupportSuspendedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_SUPPORT_RESUMED:
                            EventHandler SupportResumedHandler = this.SupportResumed;
                            if (null != SupportResumedHandler)
                            {
                                SupportResumedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_CHATTEXT_RECEIVED:
                            EventHandler ChatTextReceivedHandler = this.ChatTextReceived;
                            if (null != ChatTextReceivedHandler)
                            {
                                ChatTextReceivedHandler(this, e);
                            }
                            break;

                        /* Opcode degli eventi: media */
                        case JADA.Event.EVT_CALL_OPENED:
                            EventHandler CallOpenedHandler = this.CallOpened;
                            if (null != CallOpenedHandler)
                            {
                                CallOpenedHandler(this, e);
                            }
                            //StartAudio();
                            //myAudioRestartTimer = new System.Threading.Timer(new TimerCallback(RestartAudioTimer), null, 0, 5 * 60 * 1000);
                            break;

                        case JADA.Event.EVT_CALL_CLOSED:
                            //if (myAudioRestartTimer != null)
                            //{
                            //    myAudioRestartTimer.Dispose(); myAudioRestartTimer = null;
                            //}
                            //StopAudio();
                            EventHandler CallClosedHandler = this.CallClosed;
                            if (null != CallClosedHandler)
                            {
                                CallClosedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_CALL_ABORTED:
                            //if (myAudioRestartTimer != null)
                            //{
                            //    myAudioRestartTimer.Dispose(); myAudioRestartTimer = null;
                            //}
                            //StopAudio();
                            EventHandler CallAbortedHandler = this.CallAborted;
                            if (null != CallAbortedHandler)
                            {
                                CallAbortedHandler(this, e);
                            }
                            break;

                        /* Opcode degli eventi: VNC */
                        case JADA.Event.EVT_DESKTOP_OPENED:
                            EventHandler DesktopOpenedHandler = this.DesktopOpened;
                            if (null != DesktopOpenedHandler)
                            {
                                DesktopOpenedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_DESKTOP_REQUESTED:
                            EventHandler DesktopRequestedHandler = this.DesktopRequested;
                            if (null != DesktopRequestedHandler)
                            {
                                DesktopRequestedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_DESKTOP_CLOSED:
                            EventHandler DesktopClosedHandler = this.DesktopClosed;
                            if (null != DesktopClosedHandler)
                            {
                                DesktopClosedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_WHITEBOARD_OPENED:
                            EventHandler WhiteboardOpenedHandler = this.WhiteboardOpened;
                            if (null != WhiteboardOpenedHandler)
                            {
                                WhiteboardOpenedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_WHITEBOARD_CLEANED:
                            EventHandler WhiteboardCleanedHandler = this.WhiteboardCleaned;
                            if (null != WhiteboardCleanedHandler)
                            {
                                WhiteboardCleanedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_WHITEBOARD_CLOSED:
                            EventHandler WhiteboardClosedHandler = this.WhiteboardClosed;
                            if (null != WhiteboardClosedHandler)
                            {
                                WhiteboardClosedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_SET_DRAW_POINTER:
                            EventHandler DrawPointerMovedHandler = this.DrawPointerMoved;
                            if (null != DrawPointerMovedHandler)
                            {
                                DrawPointerMovedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_RESET_DRAW_POINTER:
                            EventHandler DrawPointerResetHandler = this.DrawPointerReset;
                            if (null != DrawPointerResetHandler)
                            {
                                DrawPointerResetHandler(this, e);
                            }
                            break;

                        /* Opcode degli eventi: FTP */
                        case JADA.Event.EVT_FTP_OPENED:
                            EventHandler HandlerFtpOpened = this.FtpOpened;
                            if (null != HandlerFtpOpened)
                            {
                                HandlerFtpOpened(this, e);
                            }
                            break;

                        case JADA.Event.EVT_DIRECTORY_LIST:
                            EventHandler DirectoryListHandler = this.DirectoryList;
                            if (null != DirectoryListHandler)
                            {
                                DirectoryListHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_FILE_SENT:
                            EventHandler FileSentHandler = this.FileSent;
                            if (null != FileSentHandler)
                            {
                                FileSentHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_FILE_RECEIVED:
                            EventHandler FileReceivedHandler = this.FileReceived;
                            if (null != FileReceivedHandler)
                            {
                                FileReceivedHandler(this, e);
                            }
                            break;

                        case JADA.Event.EVT_FTP_CLOSED:
                            EventHandler FtpClosedHandler = this.FtpClosed;
                            if (null != FtpClosedHandler)
                            {
                                FtpClosedHandler(this, e);
                            }
                            break;

                        default:
                            JADA.Common.LogMessage(String.Format("Tipo evento {0} non gestito da Connection", iEventType));
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        JADA.Common.LogMessage(String.Format("HandleEventThread {0}\n{1}", e.Message, e.StackTrace));
                        // MessageBox.Show("Errore nell'applicazione: i dettagli sono stati salvati nel file di log", "JADA");
                    }
                    finally
                    {
                        if (evtSelf != null)
                        {
                            evtSelf.Dispose();
                        }
                    }
                }
            }
        }