Send follow me request to all players
This commit is contained in:
parent
b30d0989c8
commit
1fca99c0d1
@ -8,6 +8,7 @@ import {
|
||||
BatchToPusherMessage,
|
||||
BatchToPusherRoomMessage,
|
||||
EmotePromptMessage,
|
||||
FollowMeRequestMessage,
|
||||
EmptyMessage,
|
||||
ItemEventMessage,
|
||||
JoinRoomMessage,
|
||||
@ -116,6 +117,12 @@ const roomManager: IRoomManagerServer = {
|
||||
user,
|
||||
message.getEmotepromptmessage() as EmotePromptMessage
|
||||
);
|
||||
} else if (message.hasFollowmerequestmessage()) {
|
||||
socketManager.handleFollowMeRequestMessage(
|
||||
room,
|
||||
user,
|
||||
message.getFollowmerequestmessage() as FollowMeRequestMessage
|
||||
);
|
||||
} else if (message.hasSendusermessage()) {
|
||||
const sendUserMessage = message.getSendusermessage();
|
||||
if (sendUserMessage !== undefined) {
|
||||
|
@ -30,6 +30,7 @@ import {
|
||||
BanUserMessage,
|
||||
RefreshRoomMessage,
|
||||
EmotePromptMessage,
|
||||
FollowMeRequestMessage,
|
||||
VariableMessage,
|
||||
BatchToPusherRoomMessage,
|
||||
SubToPusherRoomMessage,
|
||||
@ -833,6 +834,17 @@ export class SocketManager {
|
||||
emoteEventMessage.setActoruserid(user.id);
|
||||
room.emitEmoteEvent(user, emoteEventMessage);
|
||||
}
|
||||
|
||||
handleFollowMeRequestMessage(room: GameRoom, user: User, requestMessage: FollowMeRequestMessage) {
|
||||
console.log("Handling follow me request message");
|
||||
console.log(user.name);
|
||||
requestMessage.setPlayername(user.name);
|
||||
room.getUsers().forEach((recipient) => {
|
||||
const clientMessage = new ServerToClientMessage();
|
||||
clientMessage.setFollowmerequestmessage(requestMessage);
|
||||
recipient.socket.write(clientMessage);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export const socketManager = new SocketManager();
|
||||
|
@ -30,6 +30,7 @@ import {
|
||||
PingMessage,
|
||||
EmoteEventMessage,
|
||||
EmotePromptMessage,
|
||||
FollowMeRequestMessage,
|
||||
SendUserMessage,
|
||||
BanUserMessage,
|
||||
VariableMessage,
|
||||
@ -257,6 +258,9 @@ export class RoomConnection implements RoomConnection {
|
||||
warningContainerStore.activateWarningContainer();
|
||||
} else if (message.hasRefreshroommessage()) {
|
||||
//todo: implement a way to notify the user the room was refreshed.
|
||||
} else if (message.hasFollowmerequestmessage()) {
|
||||
const requestMessage = message.getFollowmerequestmessage() as FollowMeRequestMessage;
|
||||
console.log("Follow me request from " + requestMessage.getPlayername());
|
||||
} else if (message.hasErrormessage()) {
|
||||
const errorMessage = message.getErrormessage() as ErrorMessage;
|
||||
console.error("An error occurred server side: " + errorMessage.getMessage());
|
||||
@ -712,6 +716,14 @@ export class RoomConnection implements RoomConnection {
|
||||
this.socket.send(clientToServerMessage.serializeBinary().buffer);
|
||||
}
|
||||
|
||||
public emitFollowMeRequest(): void {
|
||||
console.log("Emitting follow me request");
|
||||
const message = new FollowMeRequestMessage();
|
||||
const clientToServerMessage = new ClientToServerMessage();
|
||||
clientToServerMessage.setFollowmerequestmessage(message);
|
||||
this.socket.send(clientToServerMessage.serializeBinary().buffer);
|
||||
}
|
||||
|
||||
public getAllTags(): string[] {
|
||||
return this.tags;
|
||||
}
|
||||
|
@ -80,6 +80,15 @@ message QueryJitsiJwtMessage {
|
||||
string tag = 2; // FIXME: rather than reading the tag from the query, we should read it from the current map!
|
||||
}
|
||||
|
||||
message FollowMeRequestMessage {
|
||||
string playerName = 1;
|
||||
}
|
||||
|
||||
message FollowMeResponseMessage {
|
||||
string playerName = 1;
|
||||
bool accepted = 2;
|
||||
}
|
||||
|
||||
message ClientToServerMessage {
|
||||
oneof message {
|
||||
UserMovesMessage userMovesMessage = 2;
|
||||
@ -95,6 +104,8 @@ message ClientToServerMessage {
|
||||
QueryJitsiJwtMessage queryJitsiJwtMessage = 12;
|
||||
EmotePromptMessage emotePromptMessage = 13;
|
||||
VariableMessage variableMessage = 14;
|
||||
FollowMeRequestMessage followMeRequestMessage = 15;
|
||||
FollowMeResponseMessage followMeResponseMessage = 16;
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,6 +296,8 @@ message ServerToClientMessage {
|
||||
WorldConnexionMessage worldConnexionMessage = 18;
|
||||
//EmoteEventMessage emoteEventMessage = 19;
|
||||
TokenExpiredMessage tokenExpiredMessage = 20;
|
||||
FollowMeRequestMessage followMeRequestMessage = 21;
|
||||
FollowMeResponseMessage followMeResponseMessage = 22;
|
||||
}
|
||||
}
|
||||
|
||||
@ -365,6 +378,8 @@ message PusherToBackMessage {
|
||||
BanUserMessage banUserMessage = 13;
|
||||
EmotePromptMessage emotePromptMessage = 14;
|
||||
VariableMessage variableMessage = 15;
|
||||
FollowMeRequestMessage followMeRequestMessage = 16;
|
||||
FollowMeResponseMessage followMeResponseMessage = 17;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@ import {
|
||||
ServerToClientMessage,
|
||||
CompanionMessage,
|
||||
EmotePromptMessage,
|
||||
FollowMeRequestMessage,
|
||||
VariableMessage,
|
||||
} from "../Messages/generated/messages_pb";
|
||||
import { UserMovesMessage } from "../Messages/generated/messages_pb";
|
||||
@ -469,6 +470,11 @@ export class IoSocketController {
|
||||
client,
|
||||
message.getEmotepromptmessage() as EmotePromptMessage
|
||||
);
|
||||
} else if (message.hasFollowmerequestmessage()) {
|
||||
socketManager.handleFollowMeRequest(
|
||||
client,
|
||||
message.getFollowmerequestmessage() as FollowMeRequestMessage
|
||||
);
|
||||
}
|
||||
|
||||
/* Ok is false if backpressure was built up, wait for drain */
|
||||
|
@ -8,6 +8,7 @@ import {
|
||||
CharacterLayerMessage,
|
||||
EmoteEventMessage,
|
||||
EmotePromptMessage,
|
||||
FollowMeRequestMessage,
|
||||
GroupDeleteMessage,
|
||||
ItemEventMessage,
|
||||
JoinRoomMessage,
|
||||
@ -269,6 +270,12 @@ export class SocketManager implements ZoneEventListener {
|
||||
this.handleViewport(client, viewport.toObject());
|
||||
}
|
||||
|
||||
handleFollowMeRequest(client: ExSocketInterface, requestMessage: FollowMeRequestMessage): void {
|
||||
const pusherToBackMessage = new PusherToBackMessage();
|
||||
pusherToBackMessage.setFollowmerequestmessage(requestMessage);
|
||||
client.backConnection.write(pusherToBackMessage);
|
||||
}
|
||||
|
||||
onEmote(emoteMessage: EmoteEventMessage, listener: ExSocketInterface): void {
|
||||
const subMessage = new SubMessage();
|
||||
subMessage.setEmoteeventmessage(emoteMessage);
|
||||
|
Loading…
Reference in New Issue
Block a user