示例#1
0
        async public static void SendRequestToClient(JStruct js)
        {
            var client = await CallExternalAppliation((c) =>
            {
                c.SendByStream2(js.JSerialize().ToByteArray(Encoding.ASCII), Engine_Code.Received);
                Logger.Log($"Request Sent from Engine: {js.JsMessage}");
            });

            if (client == null)
            {
                Logger.Log($"Couldn't Connect to External App", "", Logger.ErrorType.Warrning);
            }
        }
示例#2
0
        async private void handelconnection(TcpClient _client)
        {
            var client  = _client;
            var nstream = client.GetStream();

            try
            {
                Logger.Log($"Received data: from {_client.Client.RemoteEndPoint.AddressFamily.ToString()}");
                var resp = await client.ReadfromStream2();

                if (resp.ResponseByte.Length == 0)
                {
                    client.Dispose();
                    return;
                }
                var data = File.ReadAllBytes(resp.SavedDataPath);

                int Code = BitConverter.ToInt32(resp.ResponseByte, 0);
                Logger.Log($"Sending Code: {Code}");

                try
                {
                    ResolveTcpRequest(Code, client, resp);
                }
                catch (Exception ex)
                {
                    var js = new JStruct();
                    js.JsMessage = ex.ToString();
                    client.SendByStream2(js.JSerialize().ToByteArray(Encoding.ASCII), Engine_Code.Failed);
                    Logger.Log($"Method Number not found");
                    ex.Log("Connecting from Engine", Logger.ErrorType.Warrning);
                }
            }
            catch (Exception ex)
            {
                ex.Log(ex.Message, Logger.ErrorType.Error);
            }

            client?.Close();
        }