Example #1
0
        public async Task Send(PiranhaMessage message)
        {
            try
            {
                var asyncEvent = GetArgs;

                await message.Encode();

                message.Encrypt();

                asyncEvent.SetBuffer(await message.BuildPacket(), 0, message.Length + 7);

                asyncEvent.AcceptSocket   = message.Device.Socket;
                asyncEvent.RemoteEndPoint = message.Device.Socket.RemoteEndPoint;
                asyncEvent.UserToken      = message.Device.Token;

                await StartSend(asyncEvent);

                message.Dispose();
            }
            catch (Exception exception)
            {
                Disconnect(message.Device.Token.EventArgs);
                Logger.Log(exception, Enums.LogType.Error);
            }
        }