Comments (6)
First thing I noticed is you map a 0
then in verify response you try and get out a ulong. 0
!= 0ul
when you are mapping it out as the first would map to 4 bytes while a ulong would map to 8 bytes.
Your problem was that your first call to get the id read more data then the internall array had. It also moved the start pointer. Your next call was instructing it to get data from an already moved start pointer that was pointing out of range for the internal array hence the exception.
So your example code should be written like this:
public void AcceptChallenge(
NetWorker networker,
BMSByte challenge,
Action<BMSByte> authServerAction,
Action rejectServerAction
) {
ulong steamId = yourMethodThatGetsThis();
var data = ObjectMapper.BMSByte(steamId, Encoding.UTF8.GetBytes($"test:test"));
authServerAction(data);
}
Then on the server:
public void VerifyResponse(
NetWorker networker,
NetworkingPlayer player,
BMSByte response,
Action<NetworkingPlayer> authUserAction,
Action<NetworkingPlayer> rejectUserAction
) {
ulong steamid = response.GetBasicType<ulong>(); // <--- Moves internal array pointer.
byte[] ticketBinary = response.GetBasicType<byte[]>();
if (AuthUser(steamid, ticketBinary))
{
authUserAction(player);
}
else
{
rejectUserAction(player);
}
}
from forgenetworkingremastered.
You are correct but:
If I change as you mention, I now get an OutOfMemoryException: response.GetBasicType<byte[]>() => at x = GetBasicType(StartIndex(), true); // x gets a huge value
If I remove the steamid completely from client and server (since I do not use it), the data sent is not correctly retrieved (in my case it is an encrypted text and decryption does not recognize it).
So, there is an issue of 4 bytes somewhere...
from forgenetworkingremastered.
That is weird. Haven't seen that before and I have used byte[]s multiple times.
Just an fyi you should not touch byteArr
as that is the internal array that might not be what you expect it to be. You can get out the correct byte[] by using CompressBytes()
from forgenetworkingremastered.
So, if I do this on the client side:
var data = ObjectMapper.BMSByte(Encoding.UTF8.GetBytes($"test:test"));
authServerAction(data);
and
byte[] ticketBinary = response.CompressBytes();
on server side, the data is not correctly retrieved...
from forgenetworkingremastered.
Yes you are seeing the meta data in front. The first 4 bytes is the number of elements as an int of your byte array that you mapped in. Then you have the 9 elements.
Please use byte[] ticketBinary = response.GetBasicType<byte[]>();
You could just map the string instead of the byte array though.
from forgenetworkingremastered.
Mapping the string directly worked. Thanks! :)
from forgenetworkingremastered.
Related Issues (20)
- Null reference exception in lobby scene HOT 2
- NAT Server not functioning properly. HOT 1
- Players will not see already joined players when connecting to lobby system HOT 7
- Client loading Scene even though automaticScenes is false HOT 1
- Windows Stand Alone Player returns null reference when you instantiate in Scene 0 HOT 3
- Client in the objectCreated handler, getting a null AttachedBehavior HOT 1
- ForgeNetworkingCommon.dll not found to build StandAloneServer HOT 1
- Unity 2019.3.15 IL2CPP Build Error!
- SSL/TLS/Encryption support for TCP/UDP servers
- BeardedMath.Lerp appears incorrect for generic types
- Forge Networking Alloy networking code cannot be used without Unity due to (unused) import
- Heads up: ConcurrentQueue.TryDequeue hides member in (at least) .NET 5.0
- Consider adding relevant network object to RpcArgs HOT 2
- STEAMWORKS define symbol causes bugs HOT 1
- RPCs broken at higher pings HOT 2
- NetworkerStatistics.BandwidthInOut BREAKS at High Ping!
- No connection on iOS 14
- Wiki Documentation feedback HOT 1
- Unstable Packets (all 4 bugs which make Forge unfitting for serious projects)
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 forgenetworkingremastered.