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