Exemple #1
0
        public static byte[] DataHandler(Evaluator evl, byte[] data)
        {
            var receive = BinFormater.Read(new MemoryStream(data));

            try {
                var transactLog = new StringBuilder();
                transactLog.AppendLine($"<< {receive}");

                var res = evl.EvlSeq(receive);

                transactLog.AppendLine($">> {res}");
                Log?.Invoke(transactLog.ToString().Trim());

                if (res != null)
                {
                    return(BinFormater.Write(res).ToArray());
                }
                else
                {
                    return(new byte[0]);
                }
            } catch (Exception e) {
                var ex = e;
                var sb = new StringBuilder();
                while (ex != null)
                {
                    sb.AppendLine(ex.Message);
                    ex = ex.InnerException;
                }
                Log?.Invoke(sb.ToString());
                return(BinFormater.Write(new SpecialMessage(sb.ToString())).ToArray());
            }
        }
Exemple #2
0
            public object Call(object seq)
            {
                var resp = BinFormater.Read(new MemoryStream(Transfering.Send(BinFormater.Write(seq, _queryInterface.GetSymbolTable()).ToArray())), _queryInterface.GetSymbolTable());

                if (resp.Car() is SpecialMessage)
                {
                    OnSpecialMessageEvt(resp.Car() as SpecialMessage, seq);
                    return(null);
                }

                return(resp?.Car());
            }
Exemple #3
0
        public object Call(object seq)
        {
            if (_sendSync.Wait(5000))
            {
                var resp = BinFormater.Read(new MemoryStream(_transfering.Send(BinFormater.Write(seq, _symbolTable).ToArray())), _symbolTable);

                if (resp.Car() is SpecialMessage)
                {
                    OnSpecialMessageEvt(resp.Car() as SpecialMessage, seq);
                    return(null);
                }

                return(resp.Car());
            }
            else
            {
                // TODO connection was broken
                Console.WriteLine("Call error");
                OnConnectionError(new Exception("Call error"));
                return(null);
            }
        }
Exemple #4
0
            public object Call(object seq)
            {
                var resp = BinFormater.Read(new MemoryStream(Transfering.Send(BinFormater.Write(seq).ToArray())));

                return(resp?.Car());
            }
Exemple #5
0
            public object Call(object seq)
            {
                var resp = BinFormater.Read(new MemoryStream(Transfering.Send(BinFormater.Write(seq, _queryInterface.GetSymbolTable()).ToArray())), _queryInterface.GetSymbolTable());

                return(resp?.Car());
            }