Skip to content

Commit

Permalink
fix server.send for simple-room package
Browse files Browse the repository at this point in the history
  • Loading branch information
RSamaium committed Nov 27, 2023
1 parent f60b141 commit 3753c6a
Show file tree
Hide file tree
Showing 17 changed files with 831 additions and 167 deletions.
1 change: 0 additions & 1 deletion packages/plugins/agones/module/tests/agones.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ test('Change Server, state is shared', async () => {
mockMatchmaker.mockReturnValue(MATCH_MAKER_SERVICE[1])
await player.changeMap('map2')
const newPlayer = RpgWorld.getPlayers()[0]
expect(newPlayer.playerId).not.toBe(playerId)
expect(newPlayer.hp).toBe(100)
})

Expand Down
14 changes: 7 additions & 7 deletions packages/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"pretty-error": "^4.0.0",
"rxjs": "7.8.0",
"sat": "^0.9.0",
"simple-room": "^3.0.0",
"simple-room": "^3.0.1",
"socket.io": "^4.6.1"
},
"gitHead": "5abe6ca78be96524d74a052a230f2315c900ddee",
Expand Down
7 changes: 2 additions & 5 deletions packages/server/src/Player/Player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,11 +597,8 @@ export class RpgPlayer extends RpgCommonPlayer {
}

toJSON() {
const map = this.getCurrentMap()
if (!map) {
throw new Error('The player is not assigned to any map')
}
const snapshot = map.$snapshotUser(this.id)
const { permanentObject } = Room.compileSchema(this.schema)
const snapshot = Room.extractObjectOfRoom(this, permanentObject)
snapshot.variables = [...this.variables]
return snapshot
}
Expand Down
12 changes: 5 additions & 7 deletions packages/server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ import { SceneMap } from './Scenes/Map';
import { RpgPlayer } from './Player/Player'
import { Query } from './Query'
import { DAMAGE_SKILL, DAMAGE_PHYSIC, DAMAGE_CRITICAL, COEFFICIENT_ELEMENTS } from './presets'
import { World, WorldClass } from 'simple-room'
import { World, WorldClass, Transport } from 'simple-room'
import { Utils, RpgPlugin, Scheduler, HookServer, RpgCommonGame, DefaultInput } from '@rpgjs/common'
import { Observable } from 'rxjs';
import { Tick } from '@rpgjs/types';
import { Actor, Armor, Class, DatabaseTypes, Item, Skill, State, Weapon } from '@rpgjs/database';
import { UserState } from 'simple-room/lib/rooms/default';
import { Transport } from 'simple-room/lib/transports/socket';

export class RpgServerEngine {

Expand Down Expand Up @@ -245,11 +243,11 @@ export class RpgServerEngine {
}

private transport(io): Transport {
const timeoutDisconnect = 10000
const timeoutDisconnect = 0
const transport = new Transport(io, {
timeoutDisconnect,
auth: (socket) => {
console.log( socket.handshake.auth)
//console.log( socket.handshake.auth)
return Utils.generateUID()
}
})
Expand All @@ -271,8 +269,8 @@ export class RpgServerEngine {
* @returns {void}
* @memberof RpgServerEngine
*/
send() {
this.world.send()
send(): Promise<void> {
return this.world.send()
}

private async updatePlayersMove(deltaTimeInt: number) {
Expand Down
Loading

0 comments on commit 3753c6a

Please sign in to comment.