make use of proto well knows types
This commit is contained in:
parent
7ba3225ac4
commit
82dffff5a7
@ -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";
|
||||
|
@ -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";
|
||||
|
||||
|
@ -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/",
|
||||
|
@ -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 {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user