SHARE
TWEET

Untitled

a guest Oct 21st, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. private void OnDataReceived(object sender, DataReceivedEventArgs e)
  2. {
  3.     // зачем это?
  4.     // var message = Convert.ToBase64String(e.Data);
  5.  
  6.     var context = new SerializationContext
  7.     {
  8.         Options = SerializationOptions.SuppressTypeInformation
  9.     };
  10.     using (MemoryStream stream = new MemoryStream(e.Data))
  11.     {
  12.         var reader = new MsgPackReader(stream, context, Endianness.LittleEndian);
  13.         var value = reader.ReadValue(typeof(string));
  14.        
  15.         byte[] msgData = Convert.FromBase64String(value);
  16.         string decodedMsg = System.Text.ASCIIEncoding.ASCII.GetString(data);
  17.        
  18.         stream.Position += e.Data.Length;
  19.  
  20.         Debug.Log("Data received: " + decodedMsg);
  21.     }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top