Beispiel #1
0
 private void HandleNextRequest()
 {
     try
     {
         m_request = m_requestqueue.Dequeue();
         if (m_request.command != null)
         {
             m_connection.WriteLine("REQUEST " + m_request.command);
         }
         else
         {
             m_connection.WriteLine("REQUEST");
         }
         byte[] requestcontent = Serializer.getRequestContent(m_request.doctype, m_request.root, m_request.answertype, m_request.content);
         m_connection.WriteContent(requestcontent);
         m_answerbuf = null;
         m_state = State.WaitAnswer;
     }
     catch (InvalidOperationException)
     {
         //... no more requests in the queue
         m_state = State.Idle;
         m_request = null;
         m_answerbuf = null;
     }
 }
Beispiel #2
0
        Session(string ip, int port, string authmethod, ProcessSessionErrorDelegate processError_, ProcessAnswerDelegate processAnswer_)
        {
            m_banner = null;
            m_connection = new Connection(ip, port, ProcessConnectionErrorDelegate, ProcessConnectionMessageDelegate);
            m_authmethod = authmethod;
            m_state = State.Init;

            m_processError = processError_;
            m_processAnswer = processAnswer_;

            m_requestqueue = new Queue<Request>();
            m_request = null;
            m_answerbuf = null;
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            try
            {
                string relativeSslCertPath = "..\\..\\..\\..\\..\\..\\examples\\demo\\tutorial\\step4a\\server\\SSL\\wolframed.pfx";
                string curpath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString();
                string sslCertPath = Path.Combine( curpath, relativeSslCertPath).ToString();

                SecureString pw = new SecureString();
                char[] pwar = {'w','o','l','f','r','a','m','e',(char)0};
                for (int pi = 0; pwar[pi] != 0; ++pi) pw.AppendChar(pwar[pi]);

                var cfg = new Session.Configuration
                {
                    host = "localhost",
                    port = 7961,
                    sslcert = sslCertPath,
                    sslpassword = pw,
                    validatecert = false,
                    authmethod = "WOLFRAME-CRAM",
                    password = "******",
                    username = "******"
                };
                string pwdError;
                // if (!Session.ChangePassword(cfg, "bork124", out pwdError))
                // {
                //     Console.WriteLine("Error changing password: {0}", pwdError);
                // }

                Session session = new Session( cfg, ProcessAnswer);
                if (!session.Connect())
                {
                    Console.WriteLine("Error in connect of session: {0}", session.GetLastError());
                }
                else
                {
                    Customer customer = new Customer { Name = "Ottmar Hitzfeld", Address = "Loerrach Germany" };
                    int answerid = (int)AnswerId.CustomerInsertedObj;

                    int ii = 0;
                    for (ii = 0; ii < 10; ++ii)
                    {
                        Request request = new Request { id = answerid, command = "Insert", number = ii, doctype = "Customer", root = "customer", obj = customer, objtype = typeof(Customer), answertype = typeof(CustomerInserted) };
                        session.IssueRequest(request);
                    }
                    while (session.NofOpenRequests() > 0)
                    {
                        Thread.Sleep(200);
                    }
                    Thread.Sleep(2000);
                    Console.WriteLine("All done");
                    session.Shutdown();
                    session.Close();
                    string err = session.GetLastError();
                    if (err != null)
                    {
                        Console.WriteLine("Error in session: {0}", err);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in session: {0}", e.Message);
            }
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            try
            {
                string relativeSslCertPath = "wolframed.pfx";
                string curpath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location).ToString();
                string sslCertPath = Path.Combine( curpath, relativeSslCertPath).ToString();

                SecureString pw = new SecureString();
                char[] pwar = {'w','o','l','f','r','a','m','e',(char)0};
                for (int pi = 0; pwar[pi] != 0; ++pi) pw.AppendChar(pwar[pi]);

                var cfg = new Session.Configuration
                {
                    host = "localhost",
                    port = 7961,
                    sslcert = sslCertPath,
                    sslpassword = pw,
                    validatecert = false,
                    authmethod = null
                };
                Session session = new Session( cfg, ProcessAnswer);
                if (!session.Connect())
                {
                    Console.WriteLine("Error in connect of session: {0}", session.GetLastError());
                }
                else
                {
                    Customer customer = new Customer { Name = "Ottmar Hitzfeld", Address = "Loerrach Germany" };
                    int answerid = (int)AnswerId.CustomerInsertedObj;

                    Request request = new Request { id = answerid, command = "Insert", number = ii, doctype = "Customer", root = "customer", obj = customer, objtype = typeof(Customer), answertype = typeof(CustomerInserted) };
                    session.IssueRequest(request);

                    Thread.Sleep(1000);
                    session.Shutdown();
                    session.Close();

                    string err = session.GetLastError();
                    if (err != null)
                    {
                        Console.WriteLine("Error in session: {0}", err);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception in session: {0}", e.Message);
            }
        }
Beispiel #5
0
 private void HandleRequest(Request rq)
 {
     byte[] rqdata = m_serializer.getRequestContent(rq.doctype, rq.root, rq.objtype, rq.obj);
     m_pendingqueue.Enqueue(new PendingRequest { id = rq.id, number = rq.number, answertype = rq.answertype });
     if (rq.command != null && rq.command.Length > 0)
     {
         m_connection.WriteLine("REQUEST " + rq.command);
     }
     else
     {
         m_connection.WriteLine("REQUEST");
     }
     m_connection.WriteContent( rqdata);
 }
Beispiel #6
0
 public void IssueRequest( Request request)
 {
     m_requestqueue.Enqueue( request);
 }
Beispiel #7
0
 public void HandleUnrecoverableError(string errstr)
 {
     if (m_request != null)
     {
         m_processAnswer(new Answer { msgtype = Answer.MsgType.Error, id = m_request.id, content = errstr });
         m_request = null;
     }
     m_processError(errstr);
     ClearRequestQueue(errstr);
     m_connection.Close();
     m_state = State.Terminated;
 }