Skip to content

Commit

Permalink
fix client
Browse files Browse the repository at this point in the history
  • Loading branch information
Pospelove committed Dec 15, 2024
1 parent 2e152d7 commit 53bf59b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
6 changes: 3 additions & 3 deletions skymp5-client/src/services/events/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { SetInventoryMessage } from "../messages/setInventoryMessage";
import { OpenContainerMessage } from "../messages/openContainerMessage";
import { ChangeValuesMessage } from "../messages/changeValuesMessage";
import { CreateActorMessage } from "../messages/createActorMessage";
import { CustomPacketMessage2 } from "../messages/customPacketMessage2";
import { DestroyActorMessage } from "../messages/destroyActorMessage";
import { SetRaceMenuOpenMessage } from "../messages/setRaceMenuOpenMessage";
import { SpSnippetMessage } from "../messages/spSnippetMessage";
Expand All @@ -36,6 +35,7 @@ import { QueryBlockSetInventoryEvent } from "./queryBlockSetInventoryEvent";
import { QueryKeyCodeBindings } from "./queryKeyCodeBindings";
import { SpellCastMessage } from "../messages/spellCastMessage";
import { UpdateAnimVariablesMessage } from "../messages/updateAnimVariablesMessage";
import { CustomPacketMessage } from "../messages/customPacketMessage";


type EventTypes = {
Expand Down Expand Up @@ -64,14 +64,14 @@ type EventTypes = {
'hostStopMessage': [ConnectionMessage<HostStopMessage>],
'setInventoryMessage': [ConnectionMessage<SetInventoryMessage>],
'createActorMessage': [ConnectionMessage<CreateActorMessage>],
'customPacketMessage2': [ConnectionMessage<CustomPacketMessage2>],
'destroyActorMessage': [ConnectionMessage<DestroyActorMessage>],
'setRaceMenuOpenMessage': [ConnectionMessage<SetRaceMenuOpenMessage>],
'spSnippetMessage': [ConnectionMessage<SpSnippetMessage>],
'updateGamemodeDataMessage': [ConnectionMessage<UpdateGamemodeDataMessage>],
'updatePropertyMessage': [ConnectionMessage<UpdatePropertyMessage>],
'deathStateContainerMessage': [ConnectionMessage<DeathStateContainerMessage>],
'teleportMessage2': [ConnectionMessage<TeleportMessage2>]
'teleportMessage2': [ConnectionMessage<TeleportMessage2>],
'customPacketMessage': [ConnectionMessage<CustomPacketMessage>]

'browserWindowLoaded': [BrowserWindowLoadedEvent],
'authAttempt': [AuthAttemptEvent],
Expand Down
29 changes: 21 additions & 8 deletions skymp5-client/src/services/services/authService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { ConnectionMessage } from "../events/connectionMessage";
import { CreateActorMessage } from "../messages/createActorMessage";
import { CustomPacketMessage } from "../messages/customPacketMessage";
import { NetworkingService } from "./networkingService";
import { CustomPacketMessage2 } from "../messages/customPacketMessage2";
import { MsgType } from "../../messages";
import { ConnectionDenied } from "../events/connectionDenied";

Expand Down Expand Up @@ -46,7 +45,7 @@ export class AuthService extends ClientListener {
this.controller.emitter.on("createActorMessage", (e) => this.onCreateActorMessage(e));
this.controller.emitter.on("connectionAccepted", () => this.handleConnectionAccepted());
this.controller.emitter.on("connectionDenied", (e) => this.handleConnectionDenied(e));
this.controller.emitter.on("customPacketMessage2", (e) => this.onCustomPacketMessage2(e));
this.controller.emitter.on("customPacketMessage", (e) => this.onCustomPacketMessage(e));
this.controller.on("browserMessage", (e) => this.onBrowserMessage(e));
this.controller.on("tick", () => this.onTick());
this.controller.once("update", () => this.onceUpdate());
Expand Down Expand Up @@ -96,10 +95,24 @@ export class AuthService extends ClientListener {
this.authAttemptProgressIndicator = false;
}

private onCustomPacketMessage2(event: ConnectionMessage<CustomPacketMessage2>): void {
private onCustomPacketMessage(event: ConnectionMessage<CustomPacketMessage>): void {
const msg = event.message;

switch (msg.content["customPacketType"]) {
let msgContent: Record<string, unknown> = {};

try {
msgContent = JSON.parse(msg.contentJsonDump);
} catch (e) {
if (e instanceof SyntaxError) {
logError(this, "onCustomPacketMessage failed to parse JSON", e.message, "json:", msg.contentJsonDump);
return;
}
else {
throw e;
}
}

switch (msgContent["customPacketType"]) {
// case 'loginRequired':
// logTrace(this, 'loginRequired received');
// this.loginWithSkympIoCredentials();
Expand Down Expand Up @@ -541,12 +554,12 @@ export class AuthService extends ClientListener {
);
const message: CustomPacketMessage = {
t: MsgType.CustomPacket,
content: {
contentJsonDump: JSON.stringify({
customPacketType: 'loginWithSkympIo',
gameData: {
profileId: authData.local.profileId,
},
},
}),
};
this.controller.emitter.emit("sendMessage", {
message: message,
Expand All @@ -559,12 +572,12 @@ export class AuthService extends ClientListener {
logTrace(this, 'Logging in as a master API user');
const message: CustomPacketMessage = {
t: MsgType.CustomPacket,
content: {
contentJsonDump: JSON.stringify({
customPacketType: 'loginWithSkympIo',
gameData: {
session: authData.remote.session,
},
},
}),
};
this.controller.emitter.emit("sendMessage", {
message: message,
Expand Down

0 comments on commit 53bf59b

Please sign in to comment.