public void SendAudioSegment(ChatroomAudioDTO data) { if (OwnID == -1) { return; } var recipientID = data.id; var segmentIndex = data.segmentIndex; var frequency = data.frequency; var channelCount = data.channelCount; var samples = data.samples; var packet = new Packet().WithTag("audio") .WithPayload(new BytesWriter() .WriteInt(segmentIndex) .WriteInt(frequency) .WriteInt(channelCount) .WriteFloatArray(samples) .Bytes ); node.SendPacket(recipientID, packet, false); OnAudioSent?.Invoke(data); }
private void OnGUI() { int height = 20; int count = 0; int getHeight() { var value = height * count; count++; return(value); } GUI.Label(new Rect(0, getHeight(), 4000, height), msg); var label = node.CurrentMode == APNode.Mode.Idle ? "Not Connected. Mode" : (node.CurrentMode == APNode.Mode.Client ? "I am Client" : "I am Server") + " ID : " + node.ID; GUI.Label(new Rect(0, getHeight(), 400, height), label); address = GUI.TextField(new Rect(0, getHeight(), 400, height), address); if (GUI.Button(new Rect(0, getHeight(), 400, height), "Create")) { node.StartServer(address); } if (GUI.Button(new Rect(0, getHeight(), 400, height), "Join")) { node.Connect(address); } if (GUI.Button(new Rect(0, getHeight(), 400, height), "Leave")) { if (node.CurrentMode == APNode.Mode.Server) { node.StopServer(); } else { node.Disconnect(); } } textInput = GUI.TextField(new Rect(0, getHeight(), 400, height), textInput); if (GUI.Button(new Rect(0, getHeight(), 400, height), "Send Message")) { node.SendPacket(node.Peers, new Packet().WithTag(textInput), true); textInput = ""; } if (GUI.Button(new Rect(0, getHeight(), 400, height), "Print Peers")) { var str = "PEERS : ["; foreach (var p in node.Peers) { str += p + " "; } str += "]"; msg = (str); } }
void Update() { if (node != null) { if (node.CurrentMode == APNode.Mode.Server) { node.SendPacket(node.Peers, new Packet() .WithPayload(System.BitConverter.GetBytes(Time.frameCount))); msg2.text = "Sending " + Time.frameCount.ToString(); } } }