Esempio n. 1
0
        private void InternalSend(NetOutMessage message, string ip, int port)
        {
            IPAddress ipAddress = null;

            if (!IPAddress.TryParse(ip, out ipAddress))
            {
                return;
            }

            IPEndPoint ipEndPoint = new IPEndPoint(ipAddress, port);

            byte[] messageBytes = message.GetMessageBytes();

            NetOutMessage modifiedMessage = new NetOutMessage();

            modifiedMessage.WriteInt32(messageBytes.Length);
            modifiedMessage.WriteBytes(messageBytes);

            m_udpClient.Send(modifiedMessage.GetMessageBytes(), modifiedMessage.GetMessageBytes().Length, ipEndPoint);
        }
Esempio n. 2
0
        private async void InternalSend(NetOutMessage message, string destIP, int destPort)
        {
            HostName partnerHostName = new HostName(destIP);

            using (IOutputStream stream = await m_udpSocket.GetOutputStreamAsync(partnerHostName, destPort.ToString()))
            {
                using (DataWriter writer = new DataWriter(stream))
                {
                    byte[] data = message.GetMessageBytes();

                    writer.WriteInt32(data.Length);
                    writer.WriteBytes(data);

                    await writer.StoreAsync();
                }
            }
        }