send group userIds to players
This commit is contained in:
parent
8d8857011e
commit
724dbc8efa
@ -147,9 +147,9 @@ export class Group implements Movable {
|
||||
|
||||
join(user: User): void {
|
||||
// Broadcast on the right event
|
||||
this.connectCallback(user, this);
|
||||
this.users.add(user);
|
||||
user.group = this;
|
||||
this.connectCallback(user, this);
|
||||
}
|
||||
|
||||
leave(user: User): void {
|
||||
|
@ -38,6 +38,7 @@ import {
|
||||
SubToPusherRoomMessage,
|
||||
SetPlayerDetailsMessage,
|
||||
PlayerDetailsUpdatedMessage,
|
||||
GroupUsersUpdateMessage,
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import { User, UserSocket } from "../Model/User";
|
||||
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
|
||||
@ -265,8 +266,14 @@ export class SocketManager {
|
||||
if (roomPromise === undefined) {
|
||||
roomPromise = GameRoom.create(
|
||||
roomId,
|
||||
(user: User, group: Group) => this.joinWebRtcRoom(user, group),
|
||||
(user: User, group: Group) => this.disConnectedUser(user, group),
|
||||
(user: User, group: Group) => {
|
||||
this.joinWebRtcRoom(user, group);
|
||||
this.sendGroupUsersUpdateToGroupMembers(group);
|
||||
},
|
||||
(user: User, group: Group) => {
|
||||
this.disConnectedUser(user, group);
|
||||
this.sendGroupUsersUpdateToGroupMembers(group);
|
||||
},
|
||||
MINIMUM_DISTANCE,
|
||||
GROUP_RADIUS,
|
||||
(thing: Movable, fromZone: Zone | null, listener: ZoneSocket) =>
|
||||
@ -438,6 +445,19 @@ export class SocketManager {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private sendGroupUsersUpdateToGroupMembers(group: Group) {
|
||||
const groupUserUpdateMessage = new GroupUsersUpdateMessage();
|
||||
groupUserUpdateMessage.setGroupid(group.getId());
|
||||
groupUserUpdateMessage.setUseridsList(group.getUsers().map((user) => user.id));
|
||||
|
||||
const clientMessage = new ServerToClientMessage();
|
||||
clientMessage.setGroupusersupdatemessage(groupUserUpdateMessage);
|
||||
|
||||
group.getUsers().forEach((currentUser: User) => {
|
||||
currentUser.socket.write(clientMessage);
|
||||
});
|
||||
}
|
||||
|
||||
private joinWebRtcRoom(user: User, group: Group) {
|
||||
for (const otherUser of group.getUsers()) {
|
||||
if (user === otherUser) {
|
||||
|
@ -47,6 +47,11 @@ export interface GroupCreatedUpdatedMessageInterface {
|
||||
groupSize: number;
|
||||
}
|
||||
|
||||
export interface GroupUsersUpdateMessageInterface {
|
||||
groupId: number;
|
||||
userIds: number[];
|
||||
}
|
||||
|
||||
export interface WebRtcDisconnectMessageInterface {
|
||||
userId: number;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import type { UserSimplePeerInterface } from "../WebRtc/SimplePeer";
|
||||
import { ProtobufClientUtils } from "../Network/ProtobufClientUtils";
|
||||
import type {
|
||||
GroupCreatedUpdatedMessageInterface,
|
||||
GroupUsersUpdateMessageInterface,
|
||||
MessageUserJoined,
|
||||
PlayGlobalMessageInterface,
|
||||
PositionInterface,
|
||||
@ -97,6 +98,9 @@ export class RoomConnection implements RoomConnection {
|
||||
private readonly _groupUpdateMessageStream = new Subject<GroupCreatedUpdatedMessageInterface>();
|
||||
public readonly groupUpdateMessageStream = this._groupUpdateMessageStream.asObservable();
|
||||
|
||||
private readonly _groupUsersUpdateMessageStream = new Subject<GroupUsersUpdateMessageInterface>();
|
||||
public readonly groupUsersUpdateMessageStream = this._groupUsersUpdateMessageStream.asObservable();
|
||||
|
||||
private readonly _groupDeleteMessageStream = new Subject<GroupDeleteMessageTsProto>();
|
||||
public readonly groupDeleteMessageStream = this._groupDeleteMessageStream.asObservable();
|
||||
|
||||
@ -398,6 +402,12 @@ export class RoomConnection implements RoomConnection {
|
||||
this._sendJitsiJwtMessageStream.next(message.sendJitsiJwtMessage);
|
||||
break;
|
||||
}
|
||||
case "groupUsersUpdateMessage": {
|
||||
console.log("GOT GROUP USERS UPDATE MESSAGE");
|
||||
console.log(message.groupUsersUpdateMessage);
|
||||
this._groupUsersUpdateMessageStream.next(message.groupUsersUpdateMessage);
|
||||
break;
|
||||
}
|
||||
case "sendUserMessage": {
|
||||
adminMessagesService.onSendusermessage(message.sendUserMessage);
|
||||
break;
|
||||
|
@ -1976,7 +1976,6 @@ ${escapedMessage}
|
||||
}
|
||||
|
||||
private doShareGroupPosition(groupPositionMessage: GroupCreatedUpdatedMessageInterface) {
|
||||
console.log(groupPositionMessage);
|
||||
//delete previous group
|
||||
this.doDeleteGroup(groupPositionMessage.groupId);
|
||||
|
||||
|
@ -215,6 +215,11 @@ message ItemStateMessage {
|
||||
string stateJson = 2;
|
||||
}
|
||||
|
||||
message GroupUsersUpdateMessage {
|
||||
int32 groupId = 1;
|
||||
repeated int32 userIds = 2;
|
||||
}
|
||||
|
||||
message RoomJoinedMessage {
|
||||
//repeated UserJoinedMessage user = 1;
|
||||
//repeated GroupUpdateMessage group = 2;
|
||||
@ -310,6 +315,7 @@ message ServerToClientMessage {
|
||||
FollowRequestMessage followRequestMessage = 21;
|
||||
FollowConfirmationMessage followConfirmationMessage = 22;
|
||||
FollowAbortMessage followAbortMessage = 23;
|
||||
GroupUsersUpdateMessage groupUsersUpdateMessage = 24;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user