/// <summary> /// Send a command using TCP port /// </summary> /// <param name="mi">The method info</param> /// <param name="methodValues">The method values</param> public bool SendCommand(System.Reflection.MethodInfo mi, object[] methodValues) { // if port not open then open it if (_clsComm == null || !_clsComm.IsOpen) { _clsComm = new CommDll(); _settings.OpenComm(_clsComm); } // Serialize the method string usbp = KioskProtocol.Serialize(mi, methodValues); // send the command return(WriteData(usbp)); }
/// <summary> /// Handling the receiving message arriving from Telebox /// </summary> /// <param name="response">The response message</param> private void HandleMessage(string response) { try { // the response message is Transaction Complate event if (response.StartsWith("TransactionComplete")) { AuthorizationDetails details = KioskProtocol.GetAuthorizationDetails(response); TransactionComplateArrived(details); } // the response message is Reader Message event else if (response.StartsWith("ReaderMessageEvent")) { string response1 = response.Replace("ReaderMessageEvent", ""); int index = Convert.ToInt32(KioskProtocol.DeserializeResponse(response1), 16); // do not send the message index twice if (_lastIndex == index) { return; } _lastIndex = index; if (ReaderMessageEvent != null) { ReaderMessageEvent(index); } } // the response message is Command response else { _lastResult = KioskProtocol.DeserializeResponse(response); _autoEvent.Set(); } } catch { if (ErrorMessage != null) { ErrorMessage("Error Deserialize Response data - " + (response ?? "null")); } } }