예제 #1
0
 private void Player_OnMessageFromPeer(string id, string message)
 {
     try
     {
         byte[] receivedBytes = System.Convert.FromBase64String(message);
         bool   isRemoving    = receivedBytes[0] == 'r';
         if (receivedBytes.Length < 37)
         {
             return;
         }
         string segmentId = System.Convert.ToBase64String(receivedBytes, 1, 36);
         if (isRemoving)
         {
             marker.RemovePublicSegment(segmentId);
         }
         else
         {
             if (receivedBytes.Length < 37 + 8)
             {
                 return;
             }
             float[] data = new float[(receivedBytes.Length - 37) / sizeof(float)];
             Buffer.BlockCopy(receivedBytes, 37, data, 0, data.Length * sizeof(float));
             marker.AddSegment(data, segmentId, false);
         }
     }
     catch (Exception e)
     {
         Debug.Log("failed to parse message: " + e);
     }
 }