Comments (6)
Hi @hunkydoryrepair, thanks for the feedback.
For the uWebSockets transport I had to pass a "mocked" version of the request due to the optimizations uWebSockets does internally pruning the instance. (request is not available on async calls)
So far only the headers
are present in that mocked object: 600534c
Can you share how are you currently retrieving the IP address from the uWebSockets' so we can include it as well?
I think this is a good opportunity to start thinking on unifying all transports into a single API. For WebTransport I'm afraid we'll need a similar approach.
The mocked structure would look like this so far:
{
ip: "xxx.xxx.xxx.xxx",
headers: {
key: "value"
},
}
(Might be a good idea to provide URLs, protocol, paths, etc as well 🤔 )
from colyseus.
On the regular ws
library this is the recommendation we have in the documentation, but I'm afraid it doesn't cover all cases, using behind a proxy and/or different load-balancers:
request.headers['x-forwarded-for'] || request.socket.remoteAddress
from colyseus.
Sorry, I guess I was referring to an earlier version that did not pass in the request at all (at least, was not documented). Yes, we use x-forwarded-for and the request.connection.remoteAddress
...I've never seen a request.socket
on the request, so that's odd.
The issue we have remaining is we need the options passed to joinById
. We have a lot of data we need to do our authentication in the options passed in:
this.client.joinById( roomId, {
mapId,
token: token || 'iamguest',
isGuest: !token,
cryptoWallet: {...},
username,
world: worldId,
ver: GAME_CLIENT_VERSION,
...spawnParams,
avatar: !!token || !avatar ? '' : JSON.stringify(avatar),
lastSavedAt,
recaptchaKey,
}
We check bots, require a matching client version, require our own token registered with Stytch, we validate that the player hasn't changed since with authenticated using the save date, etc. We need it all. Switching to static onAuth not an option without the data.
from colyseus.
We do other checks, too, that require the room state, but those can probably be moved to onJoin
from colyseus.
can close this. would be nice to have the options in the onAsync, but not required.
from colyseus.
Thanks @hunkydoryrepair, let's keep this open for discussion, though - as I think for v1.0 we could provide a unified "request/context" object that is the same for every transport during static onAuth
🙏
from colyseus.
Related Issues (20)
- TypeError: roomHistory.clients is not iterable HOT 7
- [Bug]: Uncaught Error: ChangeTree: missing index for field "undefined"
- [Bug]: Map Schema Removing value creates issue HOT 2
- [Bug]: tsx must be loaded with --import instead of --loader HOT 4
- [Bug]: Cannot use Matchmaker w/o Server HOT 1
- [Bug]: Error code lost when throwing ServerError in onCreate HOT 2
- [Bug]: Cant join rooms from react typescript Application HOT 2
- [Feature]: UDP HOT 3
- [Bug]: States are not triggered in the expected order HOT 4
- [Bug]: clients and server both get stuck if the server threw an exception HOT 3
- [Bug]: When TypeScript target is "es2022", Server breaks HOT 3
- [Bug]: Module '"net"' has no exported member 'ServerOpts'. HOT 4
- Scalability and Content Security Policies inside Discord Activities (Discord Embedded SDK) HOT 1
- Server doesn't restart after 0.15 upgrade HOT 3
- Roadmap for @colyseus/schema 3.0 HOT 4
- [Feature]: Make Room have generic parameters for the UserData and AuthData (defaulting to any) HOT 2
- [Bug]: Matchmaker Player Stats can be inaccurate HOT 1
- [Bug]: Playground not working HOT 5
- [Bug]: Simultaneous joins fails due to halfway zombie seat reservation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from colyseus.