Esempio n. 1
0
        /// <summary>
        /// Sends the requested screenshot
        /// </summary>
        public static void SendScreenshot(ClientStructure client, ScreenshotDownloadRequestMsgData data)
        {
            var file = Path.Combine(ScreenshotPath, data.FolderName, $"{data.DateTaken}.png");

            if (FileHandler.FileExists(file))
            {
                var contents = FileHandler.ReadFile(file);
                var msgData  = ServerContext.ServerMessageFactory.CreateNewMessageData <ScreenshotDataMsgData>();
                msgData.Screenshot.DateTaken  = data.DateTaken;
                msgData.Screenshot.Data       = contents;
                msgData.Screenshot.NumBytes   = msgData.Screenshot.Data.Length;
                msgData.Screenshot.Height     = LunaMath.UShortFromBytes(contents[18], contents[19]);
                msgData.Screenshot.Width      = LunaMath.UShortFromBytes(contents[22], contents[23]);
                msgData.Screenshot.FolderName = data.FolderName;

                LunaLog.Debug($"Sending screenshot ({ByteSize.FromBytes(msgData.Screenshot.NumBytes).KiloBytes}{ByteSize.KiloByteSymbol}): {data.DateTaken} to: {client.PlayerName}.");
                MessageQueuer.SendToClient <ScreenshotSrvMsg>(client, msgData);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Sends the requested screenshot
        /// </summary>
        public static void SendScreenshot(ClientStructure client, ScreenshotDownloadRequestMsgData data)
        {
            Task.Run(() =>
            {
                var file = Path.Combine(ScreenshotFolder, data.FolderName, $"{data.DateTaken}.png");
                if (File.Exists(file))
                {
                    var bitmap = new Bitmap(file);

                    var msgData = ServerContext.ServerMessageFactory.CreateNewMessageData <ScreenshotDataMsgData>();
                    msgData.Screenshot.DateTaken  = data.DateTaken;
                    msgData.Screenshot.Data       = File.ReadAllBytes(file);
                    msgData.Screenshot.NumBytes   = msgData.Screenshot.Data.Length;
                    msgData.Screenshot.Height     = (ushort)bitmap.Height;
                    msgData.Screenshot.Width      = (ushort)bitmap.Width;
                    msgData.Screenshot.FolderName = data.FolderName;

                    LunaLog.Debug($"Sending screenshot ({msgData.Screenshot.NumBytes} bytes): {data.DateTaken} to: {client.PlayerName}.");
                    MessageQueuer.SendToClient <ScreenshotSrvMsg>(client, msgData);
                }
            });
        }