Skip to content

Commit

Permalink
#147 feat: Shapeのレコード更新を画面共有に対応
Browse files Browse the repository at this point in the history
  • Loading branch information
ienaga committed Jul 19, 2024
1 parent 96cc389 commit 59c6872
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const execute = (
work_space_id: number,
movie_clip_id: number,
shape_object: ShapeSaveObjectImpl,
recodes: Float32Array,
recodes: Float32Array | number[],
bounds: BoundsImpl,
file_id: string = ""
): HistoryObjectImpl => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const execute = async (
if (!receiver && $useSocket()) {
await new Promise<void>((reslove): void =>
{
const buffer = recodes.slice();
const buffer = new Float32Array(recodes);

// 圧縮が完了したらバイナリデータとして返却
worker.onmessage = async (event: MessageEvent): Promise<void> =>
Expand All @@ -106,7 +106,7 @@ export const execute = async (
// 転送用の履歴オブジェクトを作成
const historyObject = libraryAreaUpdateShapeGraphicsHistoryObjectService(
work_space.id, movie_clip.id, shapeObject,
new Float32Array(), bounds, fileId
[], bounds, fileId
);

shareSendService(historyObject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ import type { MovieClip } from "@/core/domain/model/MovieClip";
import type { BoundsImpl } from "@/interface/BoundsImpl";
import { $getWorkSpace } from "@/core/application/CoreUtil";
import { execute as externalShapeApplyGraphicsUseCase } from "@/external/core/application/ExternalShape/usecase/ExternalShapeApplyGraphicsUseCase";
import { execute as shareGetS3EndPointRepository } from "@/share/domain/repository/ShareGetS3EndPointRepository";
import { execute as shareGetS3FileRepository } from "@/share/domain/repository/ShareGetS3FileRepository";
import { execute as binaryToBufferService } from "@/core/service/BinaryToBufferService";

// @ts-ignore
import ZlibInflateWorker from "@/worker/ZlibInflateWorker?worker&inline";

/**
* @type {Worker}
* @private
*/
const worker: Worker = new ZlibInflateWorker();

/**
* @description socketで受け取った情報の受け取り処理関数
Expand Down Expand Up @@ -35,14 +47,30 @@ export const execute = async (message: ShareReceiveMessageImpl): Promise<void> =
if (!shape) {
return ;
}
// バイナリをUint8Arrayに変換
const url = await shareGetS3EndPointRepository(message.data[5] as string, "get");
const binary = await shareGetS3FileRepository(url);
const buffer: Uint8Array = binaryToBufferService(binary);

return new Promise((reslove): void =>
{
// 解凍が完了したらバイナリデータとして返却
worker.onmessage = async (event: MessageEvent): Promise<void> =>
{
// Shapeのグラフィックスを更新
await externalShapeApplyGraphicsUseCase(
workSpace,
movieClip,
shape,
new Float32Array(event.data), // 解凍したデータをFloat32Arrayに変換
message.data[4] as BoundsImpl,
true
);

reslove();
};

// Shapeのグラフィックスを更新
await externalShapeApplyGraphicsUseCase(
workSpace,
movieClip,
shape,
message.data[3] as number[],
message.data[4] as BoundsImpl,
true
);
// サブスレッドで解答処理を行う
worker.postMessage(buffer, [buffer.buffer]);
});
};

0 comments on commit 59c6872

Please sign in to comment.