public void Respond() { PosInterface posObj = new PosInterface(); Transaction transObj = new Transaction(); Thread.Sleep(400); try { //transObj.WriteLog("request ISO message: {"+ Encoding.ASCII.GetString(msg)+"}"); IsoMessage request = mfact.ParseMessage(msg, 0); IsoMessage response = new IsoMessage(); switch (request.Type.ToString("x")) { //pos request logon/logoff case "800": { response = posObj.PosSignOnOff(request); break; } //pos request download case "200": { response = posObj.Download(request); break; } //pos logon default: { response = posObj.PosSignOnOff(request); break; } } //Response message byte[] outGoing = response.getByte(4, true); Console.Out.WriteLine(System.Text.Encoding.ASCII.GetString(outGoing)); response.Write(sock.GetStream(), 4, true); //Console.Out.WriteLine("Sending response conf {0}", response.GetField(39)); ////response.Write(sock.GetStream(), 4, true); //Console.Out.WriteLine("Parsing outgoing: {0}", Encoding.ASCII.GetString(response.getByte(4, false))); //byte[] outGoing = response.getByte(4, true); //sock.GetStream().Write(outGoing, 0, outGoing.Length); //IsoMessage OutGoingMSG = mfact.ParseMessage(outGoing, 4); //PrintMessage(incoming); //PrintMessage(OutGoingMSG); //<parse type="0800"> //<field num="2" type="LLVAR" length="0" /> <!--mã đại lý --> //<field num="7" type="NUMERIC" length="10"/> <!--Transaction Date and Time --> //<field num="11" type="NUMERIC" length="6" /> <!--System Trace--> //<field num="18" type="NUMERIC" length="4" /> <!--Merchant Type: Giá trị là 6011 đối với POS--> //<field num="32" type="LLVAR" length="0" /> <!--Acquiring Institution Identification Code--> //<field num="48" type="LLVAR" length="0" /> <!--nội dung hướng dẫn --> //<field num="52" type="LLLVAR" length="0" /> <!--Đưa mã máy POS vào--> //<field num="70" type="LLLVAR" length="0" /> <!--kiểu network request cần xử lý- 001: Signon- 002: Signoff- 161: Key Exchange--> // </parse> } catch (IOException ex) { transObj.WriteLog("Fail to response, ex=" + ex.ToString()); } }