Wow this is the solution! Thank you so much!
What i am trying to do is receiving infrared from a laser gun and send this over mqtt to trigger an effect. It is not the best and cleanest way to do it. but it does the job for me.
For example in this way of using there is no check if full string is received and that stuff but i am not going to burn my hands on that. Thanks again!