Esempio n. 1
0
        /// <summary>
        /// Sends customized string to peer.
        /// </summary>
        public void SendCustomMessage(string customMessage)
        {
            if (networkConnectionState.Value != ConnectionState.publicPeer && networkConnectionState.Value != ConnectionState.localPeer)
            {
                return;
            }

            IPEndPoint endPoint = (networkConnectionState.Value == ConnectionState.publicPeer) ? peerIP.GetPublicIPEndPoint() : peerIP.GetLocalIPEndPoint();

            DataPacket packet = new DataPacket(Header.custom_message, customMessage);

            UdpNetwork.SendData(JsonConvert.SerializeObject(packet), endPoint);
        }
Esempio n. 2
0
        private void SendPacket(Message message)
        {
            UdpNetwork.SendData(JsonConvert.SerializeObject(message.packet), message.ipEndPoint);

            Debug.Log(message.packet.Header);
        }