// -- Public Utility Functions // Send packet with prepended component ID in buffer public void SendComponent(UPP_Component a_component, byte[] a_message) { // Pre checks if (a_component == null) { return; } if (twoWaySocket == null) { CloseManager(); return; } if (a_message.Length <= 0) { return; } // Create new buffer byte[] buffer = new byte[a_message.Length + 1]; // Prepend ID buffer[0] = (byte)a_component.ID; //TODO: Fix unsafe case // Copy buffer contents Buffer.BlockCopy(a_message, 0, buffer, 1, a_message.Length); // Send packet twoWaySocket.SendPacket(buffer); }
// Send component string message public void SendComponent(UPP_Component a_component, string a_message) { //Encode string to UTF8 bytes SendComponent(a_component, Encoding.UTF8.GetBytes(a_message)); }