diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index f1dbde13..5cfc85c1 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -41,7 +41,7 @@ import { SetPlayerDetailsMessage as SetPlayerDetailsMessageTsProto, PingMessage as PingMessageTsProto, CharacterLayerMessage, -} from "../Messages/ts-proto-generated/messages"; +} from "../Messages/ts-proto-generated/protos/messages"; import { Subject } from "rxjs"; import { selectCharacterSceneVisibleStore } from "../Stores/SelectCharacterStore"; import { gameManager } from "../Phaser/Game/GameManager"; diff --git a/front/src/Network/ProtobufClientUtils.ts b/front/src/Network/ProtobufClientUtils.ts index 3e172d0f..beec3d9f 100644 --- a/front/src/Network/ProtobufClientUtils.ts +++ b/front/src/Network/ProtobufClientUtils.ts @@ -1,4 +1,4 @@ -import { PositionMessage, PositionMessage_Direction } from "../Messages/ts-proto-generated/messages"; +import { PositionMessage, PositionMessage_Direction } from "../Messages/ts-proto-generated/protos/messages"; import type { PointInterface } from "../Connexion/ConnexionModels"; diff --git a/messages/package.json b/messages/package.json index 644065c9..4cef28dd 100644 --- a/messages/package.json +++ b/messages/package.json @@ -6,7 +6,7 @@ "proto": "grpc_tools_node_protoc --plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts --grpc_out=generated --js_out=\"import_style=commonjs,binary:generated\" --ts_out=generated -I ./protos protos/*.proto", "ts-proto": "grpc_tools_node_protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=ts-proto-generated --ts_proto_opt=oneof=unions --ts_proto_opt=esModuleInterop=true protos/*.proto", "copy-to-back": "rm -rf ../back/src/Messages/generated && cp -rf generated/ ../back/src/Messages/generated", - "copy-to-front-ts-proto": "sed 's/import { Observable } from \"rxjs\";/import type { Observable } from \"rxjs\";/g' ts-proto-generated/protos/messages.ts > ../front/src/Messages/ts-proto-generated/messages.ts", + "copy-to-front-ts-proto": "cp -rf ts-proto-generated/* ../front/src/Messages/ts-proto-generated/ && sed -i 's/import { Observable } from \"rxjs\";/import type { Observable } from \"rxjs\";/g' ../front/src/Messages/ts-proto-generated/protos/messages.ts", "copy-to-pusher": "rm -rf ../pusher/src/Messages/generated && cp -rf generated/ ../pusher/src/Messages/generated", "json-copy-to-pusher": "rm -rf ../pusher/src/Messages/JsonMessages/* && cp -rf JsonMessages/* ../pusher/src/Messages/JsonMessages/", "json-copy-to-back": "rm -rf ../back/src/Messages/JsonMessages/* && cp -rf JsonMessages/* ../back/src/Messages/JsonMessages/", diff --git a/messages/protos/messages.proto b/messages/protos/messages.proto index 4ddb3941..35db5321 100644 --- a/messages/protos/messages.proto +++ b/messages/protos/messages.proto @@ -1,5 +1,7 @@ syntax = "proto3"; +import "google/protobuf/wrappers.proto"; + /*********** PARTIAL MESSAGES **************/ message PositionMessage { @@ -189,8 +191,8 @@ message BatchMessage { message GroupUpdateMessage { int32 groupId = 1; PointMessage position = 2; - int32 groupSize = 3; - bool locked = 4; + google.protobuf.UInt32Value groupSize = 3; + google.protobuf.BoolValue locked = 4; } message GroupDeleteMessage { diff --git a/pusher/src/Model/Zone.ts b/pusher/src/Model/Zone.ts index 02a01d8d..f3b15ed2 100644 --- a/pusher/src/Model/Zone.ts +++ b/pusher/src/Model/Zone.ts @@ -22,6 +22,7 @@ import { import { ClientReadableStream } from "grpc"; import { PositionDispatcher } from "_Model/PositionDispatcher"; import Debug from "debug"; +import { BoolValue, UInt32Value } from "google-protobuf/google/protobuf/wrappers_pb"; const debug = Debug("zone"); @@ -125,9 +126,9 @@ export class UserDescriptor { export class GroupDescriptor { private constructor( public readonly groupId: number, - private groupSize: number, + private groupSize: number | undefined, private position: PointMessage, - private locked: boolean + private locked: boolean | undefined ) {} public static createFromGroupUpdateZoneMessage(message: GroupUpdateZoneMessage): GroupDescriptor { @@ -150,9 +151,13 @@ export class GroupDescriptor { throw new Error("GroupDescriptor.groupId is not an integer: " + this.groupId); } groupUpdateMessage.setGroupid(this.groupId); - groupUpdateMessage.setGroupsize(this.groupSize); + if (this.groupSize !== undefined) { + groupUpdateMessage.setGroupsize(new UInt32Value().setValue(this.groupSize)); + } groupUpdateMessage.setPosition(this.position); - groupUpdateMessage.setLocked(this.locked); + if (this.locked !== undefined) { + groupUpdateMessage.setLocked(new BoolValue().setValue(this.locked)); + } return groupUpdateMessage; } }