Beispiel #1
0
 public WmEAnpQueryCoreOp(EAnpIncomingQuery incomingQuery, WmCoreOp coreOp, AnpMsg res)
 {
     m_incomingQuery = incomingQuery;
     m_coreOp        = coreOp;
     m_res           = res;
 }
Beispiel #2
0
 /// <summary>
 /// Have the core operation specified parse the command specified. The
 /// core operation is returned for convenience.
 /// </summary>
 private WmCoreOp MakeCoreOpFromCmd(WmCoreOp op, AnpMsg cmd)
 {
     op.Parse(cmd);
     return(op);
 }
Beispiel #3
0
 public WmEAnpQueryCoreOp(EAnpIncomingQuery incomingQuery, WmCoreOp coreOp, AnpMsg res)
 {
     m_incomingQuery = incomingQuery;
     m_coreOp = coreOp;
     m_res = res;
 }
Beispiel #4
0
        /// <summary>
        /// Called when an incoming query is received.
        /// </summary>
        public void HandleIncomingQuery(Object sender, EAnpIncomingQueryEventArgs args)
        {
            // Get the query.
            EAnpIncomingQuery query = args.Query;

            if (!query.IsPending())
            {
                return;
            }

            // Create the result message.
            AnpMsg res = new AnpMsg();

            res.Type = (uint)EAnpRes.OK;

            // Dispatch.
            WmCoreOp coreOp = null;

            try
            {
                AnpMsg  cmd = query.Cmd;
                EAnpCmd t   = (EAnpCmd)cmd.Type;

                // Commands with core operations.
                if (t == EAnpCmd.RegisterKps)
                {
                    coreOp = MakeCoreOpFromCmd(new WmCoreOpRegisterKps(), cmd);
                }
                else if (t == EAnpCmd.SetKwsTask)
                {
                    coreOp = MakeCoreOpFromCmd(new KwsCoreOpSetKwsTask(), cmd);
                }
                else if (t == EAnpCmd.SetLoginPwd)
                {
                    coreOp = MakeCoreOpFromCmd(new KwsCoreOpSetLoginPwd(), cmd);
                }
                else if (t == EAnpCmd.CreateKws)
                {
                    coreOp = MakeCoreOpFromCmd(new KwsCoreOpCreateKws(), cmd);
                }
                else if (t == EAnpCmd.InviteKws)
                {
                    coreOp = MakeCoreOpFromCmd(new KwsCoreOpInviteKws(), cmd);
                }
                else if (t == EAnpCmd.LookupRecAddr)
                {
                    coreOp = MakeCoreOpFromCmd(new WmCoreOpLookupRecAddr(), cmd);
                }
                else if (t == EAnpCmd.ChatPostMsg)
                {
                    coreOp = MakeCoreOpFromCmd(new KwsCoreOpChatPostMsg(), cmd);
                }
                else if (t == EAnpCmd.PbAcceptChat)
                {
                    coreOp = MakeCoreOpFromCmd(new KwsCoreOpPbAcceptChat(), cmd);
                }

                // Commands without core operations.
                else if (t == EAnpCmd.ExportKws)
                {
                    HandleExportKws(cmd, res);
                }
                else if (t == EAnpCmd.ImportKws)
                {
                    HandleImportKws(cmd, res);
                }
                else if (t == EAnpCmd.VncCreateSession)
                {
                    HandleVncCreateSession(cmd, res);
                }
                else if (t == EAnpCmd.VncJoinSession)
                {
                    HandleVncJoinSession(cmd, res);
                }
                else if (t == EAnpCmd.CheckEventUuid)
                {
                    HandleCheckEventUuid(cmd, res);
                }
                else if (t == EAnpCmd.FetchEvent)
                {
                    HandleFetchEvent(cmd, res);
                }
                else if (t == EAnpCmd.FetchState)
                {
                    HandleFetchState(cmd, res);
                }

                // Eeep!
                else
                {
                    res.Type = (UInt32)EAnpRes.Failure;
                    (new EAnpExGeneric("invalid EAnp command type")).Serialize(res);
                }
            }

            catch (Exception ex)
            {
                res.Type = (UInt32)EAnpRes.Failure;
                res.ClearPayload();
                EAnpException castedEx = EAnpException.FromException(ex);
                castedEx.Serialize(res);
            }

            if (!query.IsPending())
            {
                return;
            }

            // We got a core operation. Start it.
            if (coreOp != null)
            {
                try
                {
                    WmEAnpQueryCoreOp qco = new WmEAnpQueryCoreOp(query, coreOp, res);
                    qco.Start();
                }

                catch (Exception ex)
                {
                    KBase.HandleException(ex, true);
                }
            }

            // Reply to the query right away.
            else
            {
                query.Reply(res);
            }
        }
Beispiel #5
0
 /// <summary>
 /// Have the core operation specified parse the command specified. The
 /// core operation is returned for convenience.
 /// </summary>
 private WmCoreOp MakeCoreOpFromCmd(WmCoreOp op, AnpMsg cmd)
 {
     op.Parse(cmd);
     return op;
 }