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