RakNet
BlitzMax Modules Forums/Brucey's Modules/RakNet
You're going to hate me even more. Brucey, you mentioned you had wrapped RakNet a while back....
I'm not sure if anyone else is still using jimons wrapper of RakNet (requires no .dll) aside from myself, but that was back during v 3.2, and there has been a fair amount of updates since then to RakNet itself.
His wrapper has been stable enough to use live, but there are plenty of features missing, or not working that would be a nice plus to have.
I made a miserable attempt to update the wrapper to the latest version, but the whole memory override with raknet overpowered me as it seems to have changed a lot. Unfortunately, that leads me to bug you again =(
Any hopes of adding the mod to the svn? It seriously has to be the one of the greatest network libs in existence, and i'm sure more than myself could get a lot of use from the updated version.
What's not working?
Security functions seem glitched, rakvoice wasn't included, and many other functions that were left out. On the bare minimum of it, it has the highest priority of features (bitstream being the main)...it's just missing a few 'extras' that would be nice, along with lacking some bug fixes from the updated versions.
It would have been easier for me to impliment the rest of the functions in 3.2, but i'm unable to find the rest of raknet source for that version, and it seems like it would be backtracking to update an older version of a library.
Ive stayed with v3.32 of jimons wrapper but had to add a few functions to get it to work exactly as I wanted. (if you want 3.32 src rtime I can upload a copy np)
I found that the statistics side of things didnt seem to work correctly but I skipped past it as I didnt really need it (along with RakVoice)
One major lacking function I had to add was
const char* GetIPAddressFromIndex( int index );
All in all its a nice wrapper but IM with reTimer, its a shame its not been updated (Raknet is constantly being updated)
My API ain't flat like jimons.... (as you'd expect, I suppose?)
const char* GetIPAddressFromIndex( int index );
Yeah haha, I went ahead and came up with this for getting remote ips with a simplified wrap of jimons wrap I made called EasyRak. Nothing needed to be done to jimons source. Been a while since I made the module and had to use the function, but I think this is what I used:
Method GetRemoteIp:String(Index:Int)
Return EasyRak_DotIP(RN_SystemAddressGetBinaryAddress(RN_GetSystemAddressFromIndex(Self.Interface, Index)))
End Method
Function EasyRak_DotIP:String(IP:Int)
Return (ip & 255) + "." + (ip Shr 8 & 255) + "." + (ip Shr 16 & 255) + "." + (ip Shr 24)
End Function
I also forgot to mention about the statistics, thanks for mentioning that.
And if you could, I would really appreciate a link to that 3.2 source as I think Bruceys plate is too full or has other foods for thought at the moment. I'm unsure why there isn't older versions provided on the rak website =/
Actually, I've been fighting this line of late :
rakPeer1.InitializeSecurity(Null, Null, p, q)
The bugger locks up inside of Raknet...
The bugger locks up inside of Raknet...
So, I've found a bug in Raknet... I've fixed it, but I can't say I'm impressed... given that I've wasted a few hours of my life debugging RCACrypt.. joys :-p
It seriously has to be the one of the greatest network libs in existence
I'm not so sure :-p
I rewrote my own code 3 times before attacking RakNet for the problem... I am at this moment, not filled with optimism towards some of the other parts of the API I've still to venture upon...
I'm not so sure :-p
I understand where you're coming from with the actual source though..between updates of raknet, there's a lot of undocumented and screwy transitions I noticed comparing the limited source I have between 3.2 and the new 3.3.x.
It's nothing short of a challenge, and if you want to focus on other things that's totally cool. When I ask for assistance, I feel like an ass because I don't get this tier of help from paid customer support.
I thought maybe you had already done a complete wrap of it, and was just asking if you could publish it, but if there's too much work to be done with it, no worries.
I may be wrong anyhow...I figured there was more people out there looking for a better/easier library to work with for online games/apps, but it appears there's only a couple of us with high hopes.
I thought maybe you had already done a complete wrap
Just a "most" wrap, since I hadn't intended using things like the RSA functionality ;-)
Currently I'm just going through and porting those samples, and tweaking my code as I go... (which would be now much more complete were I not
bugfixing Raknet )
Anyhoo, if you have a lot of Raknet integration already, you may not want to re-code it to support a OOP API.
(which would be now much more complete were I not bugfixing Raknet )
Nice find! I wonder how long it has been like that...
Anyhoo, if you have a lot of Raknet integration already, you may not want to re-code it to support a OOP API.
The wrap of a wrap I used (posted in blitzmax programming) would make it less difficult to go through such a transition. For what it's worth i'm as excited as a kid in toys'r'us about your work on this. Very anticipated.
I wonder how long it has been like that...
Possibly a while. I think the fact I develop on Mac helps to pick up on these, as it tends to lock up as soon as you step out of bounds (data-wise).
Very anticipated.
The examples are making me crazy at the moment. I can almost port straight to BlitzMax, but I keep missing *stupid* things which have me spending far too much time-wasting on.
Example :
peer2->Connect("127.0.0.1", 60000,0,0)
The third param is passwordData, a String. Obviously, if you pass 0 in BlitzMax you actually pass "0", unlike in C++ which is Null. So you get weird things happening... and you look at the code til you're blue in the face, and can't "see" the problem :-p
Anyhoo... I think I'm on top of it now ;-)
I've also knocked together a little CEGUI-based "helper" framework for some of the samples, since the C++ samples mix text output with no-wait key input. So I went the route of a Graphics window, and CEGUI dialogs for text input. Works rather well actually, and of course runs concurrently with the network processing, so while you are typing something in, you may see a message pop up in the background.
Anyway, back to the examples - there's a lot of them!!
I've also knocked together a little CEGUI-based "helper" framework for some of the samples
Nice. I tend to be using cegui for everything nowadays as well - so little work required to make something look fancy. Glad you're getting somewhere with it.
I'm really looking forward to the rakVoice support =p. Nothing like a little p2p support for voice chat haha.
I'm really looking forward to the rakVoice support
Yeah... I dunno how I'm going to test that!?!
The one example I used allowed you to output sound, and it would reverb back a second later. I think they all work that way (the examples appear to just be different sound systems). Otherwise, i'm available if you need an additional client/host to test with.
Just so there's something to play with for now while I work through the rest of the examples :
raknet_example_win32.rar (2.7 meg)
Showing the CEGUI-based framework for the examples. In this one, it's the basic Chat Client/Server. Not the most exciting in the world, but it does show things like banning and stats, which may be of interest.
As usual, the wrap compares closely with the original API...
printf("My GUID is %s\n", client->GetGuidFromSystemAddress(UNASSIGNED_SYSTEM_ADDRESS).ToString());
vs
AddMessage "My GUID is " + client.GetGuidFromSystemAddress(UNASSIGNED_SYSTEM_ADDRESS).ToString()
and
rss=client->GetStatistics(client->GetSystemAddressFromIndex(0));
vs
rss = client.GetStatistics(client.GetSystemAddressFromIndex(0))
Which makes porting the examples a case of copy/paste/tweak... more or less ;-)
Good stuff. Working perfect on my side.
Works perfectly here too, exciting stuff
! Just noticed that you added raknet.mod to the svn along with a few more examples...all of which appear to be working perfect as well.
Either my chair massager is on or i'm just excited =p
The examples were taking longer than I thought they would - as I have to rearrange things a little to fit into my helper-framework. So I thought I may as well drop the module into SVN for now.
I think most of the core stuff is complete.
Still working my way through the "plugins".
I've decided that RakVoice will be best kept as another module. Same with Lobby2. Otherwise you'd get all of that extra stuff compiled in, every time. This way, you get to choose.
I could probably do the same for some of those other plugins, but they seemed small enough not to matter too much.
Edit : it's the documentation that takes most of the time though.... *phew*
Edit : it's the documentation that takes most of the time though.... *phew*
I bet!...I assume you have to rely on good documentation on the other side, and sometimes figure out what the heck a function does on your own a lot of the time.
As for the examples, perhaps me and/or Ovine (if he's up for it?) can save you some time by referring to your current examples and setting up the other examples (the ones without the use of rakvoice/lobby/updater/..) in the same way, and throwing them back to you for review?
This module was an important request to me so i'de love to help in any way i'm capable if it means you can forward the time saved on the rest of the features sooner.
I might try and implement the Voice callback stuff in C++ - most of which doesn't really require BlitzMax interaction anyway - since all it needs to do is feed audio buffers with data.
That way, I should avoid any potential issues with threads.
I was considering perhaps a base BaH.RakVoice, then one for each of, FMOD, BASS, irrKlang, OpenAL, PortAudio... - well, no harm in having some options available?
Since there are already basic examples for PortAudio, DSound and FMOD, it shouldn't be too hard to work out the rest.
I've also swapped libspeex with the latest version - it appears to compile, but until I try to build an app, won't know if everything has linked properly :-p
That sounds pretty awesome. I can't imagine the possibilities with that....I look forward to creating a p2p voice chat feature for my lobby so people can spam music in their own channels (as...ofcourse they will clearly do).
A bit unrelated, but will there be a method for TRKBitStream, for 'ignorebits'? It doesn't appear to be supported within the type..maybe i'm missing it.
...for 'ignorebits'
Ooops. Added now.
Thanks!
I just tried to port over BigPacketTest example, and it appears to work, however for the sake of sanity BIG_PACKET_SIZE should probobly be 20739, or 207390, but 2073900 as the size nearly freezes my (well above average) dev computer....i'm thinking it's because of how the string is assigned differently from the port.
raknet.mod/examples/BigPacketTest.bmx
Framework BaH.Raknet
Import brl.StandardIO
Import brl.retro
Import "example_helper.bmx"
New BigPacketTest.Run()
Type BigPacketTest Extends TExampleHelper
'Stages
Const Stage_RequestingRole:Int = 1
Const Stage_RequestingIP:Int = 2
Field Quit:Byte
Field sentPacket:Byte = False
Field RakNet:TRKRakNet = New TRKRakNet
Const BIG_PACKET_SIZE:Int = 2073900
Field Text:String
Field nextStatTime:Int
Field Stage:Int
Field peer1:TRKRakPeerInterface, peer2:TRKRakPeerInterface
Field Go:Int
Field Start:Int, Stop:Int
Method Init()
Super.Init()
nextStatTime = RakNet.GetTime() + 1000
AddMessage("This is a test I use to test the packet splitting capabilities of RakNet")
AddMessage("All it does is send a large block of data to the feedback loop")
AddMessage("Difficulty: Beginner")
Stage = Stage_RequestingRole
RequestValue("Server or Client?", "Enter 's' to run as sender, 'r' to run as receiver, space/nil to run local.")
End Method
Method RenderExtra()
End Method
Method Finalize()
stop = raknet.GetTime()
Local seconds:Double = (stop - start) / 1000.0
If peer2
Local rssSender:TRKRakNetStatistics = peer2.GetStatistics(peer2.GetSystemAddressFromIndex(0))
Print(rssSender.ToVerboseString(2))
Print(Int(BIG_PACKET_SIZE / seconds) + " bytes per second transfered.")
Text = Null
TRKRakNetworkFactory.DestroyRakPeerInterface(peer1)
TRKRakNetworkFactory.DestroyRakPeerInterface(peer2)
End If
End Method
Method Update()
start = RakNet.GetTime()
If quit Then
Finalize()
End If
If peer2 Then
peer2.DeallocatePacket(peer2.Receive())
If sentPacket = False And peer2.GetSystemAddressFromIndex(0) <> UNASSIGNED_SYSTEM_ADDRESS Then
sentPacket = True
For Local i:Int = 0 To big_packet_size - 1
Text:+Chr(255)
Next
peer2.Send(Text, BIG_PACKET_SIZE, HIGH_PRIORITY, RELIABLE_ORDERED, 0, peer2.GetSystemAddressFromIndex(0), False)
'Keep the stat from updating until the messages move to the thread or it quits right away
nextStatTime = RakNet.GetTime() + 1000
End If
End If
If peer1 Then
Local packet:TRKPacket = peer1.Receive()
While packet
If packet.GetData()[0] = ID_DOWNLOAD_PROGRESS
Local ProgressBS:TRKBitStream = New TRKBitStream
ProgressBS.CreateFromData(packet.GetData(), packet.GetLength(), False)
ProgressBS.IgnoreBits(8) ' ID_DOWNLOAD_PROGRESS
Local progress:Int
Local total:Int
Local partLength:Int
Local rss:TRKRakNetStatistics = peer1.GetStatistics(peer1.GetSystemAddressFromIndex(0))
Local Data:String
ProgressBS.ReadInt(progress)
ProgressBS.ReadInt(total)
ProgressBS.ReadInt(partLength)
data = ProgressBS.ReadString(partLength)
Print "Progress: msgID=" + Asc(data[0]) + " Progress " + progress + "/" + total + " Partsize=" + partLength + " Full=" + rss.bandwidthExceeded()
'addmessage("Progress: msgID=" + Asc(data[0]) + " Progress " + progress + "/" + total + " Partsize=" + partLength + " Full=" + rss.bandwidthExceeded())
ElseIf packet.GetData()[0] >= ID_USER_PACKET_ENUM
If packet.GetData()[0] = 255 Then
Local dataValid:Byte = True
For i:Int = 1 To BIG_PACKET_SIZE - 1
If packet.GetData()[i] <> 255 Then
dataValid = False
Exit
End If
Next
If dataValid Then
Print("Test succeeded. " + packet.GetLength() + " bytes.")
Else
Print("Test failed. " + packet.GetLength() + " bytes.")
End If
Else
Print("Unkown packet " + packet.GetData()[0] + ": Test failed. " + packet.GetLength() + " bytes.")
End If
quit = True
End If
peer1.DeallocatePacket(packet)
packet = peer1.Receive() ;
WEnd
End If
If RakNet.GetTime() > nextStatTime Then
nextStatTime = RakNet.GetTime() + 1000
Local rssSender:TRKRakNetStatistics
Local rssReceiver:TRKRakNetStatistics
If peer2 Then
rssSender = peer2.GetStatistics(peer2.GetSystemAddressFromIndex(0))
If rssSender Then
Print("Snd: " + rssSender.messageSendBuffer(HIGH_PRIORITY) + " waiting. " + rssSender.messagesOnResendQueue() + " waiting on ack. Got " + rssSender.acknowlegementsReceived() + " acks. KBPS=" + (rssSender.bitsPerSecond() / 1000.0) + " Ploss=" + 100.0 * rssSender.messagesTotalBitsResent() / Float(Rsssender.totalBitsSent()) + " Full=" + rssSender.bandwidthExceeded())
If peer1 = Null
Print() 'newline??
End If
If sentPacket And rssSender.messageSendBuffer(HIGH_PRIORITY) = 0 And rsssender.messagesOnResendQueue() = 0 And peer1 = Null Then
rss = peer2.GetStatistics(peer2.GetSystemAddressFromIndex(0))
Text = rss.ToString()
rss.ToVerboseString(2)
Print(Text)
Print("Sender quitting with no messages on resend queue.")
quit = True
End If
End If
End If
If peer1 Then
rssReceiver = peer1.GetStatistics(peer1.GetSystemAddressFromIndex(0))
If rssReceiver
Print("Receiver: " + rssReceiver.acknowlegementsPending() + " acks waiting.")
End If
End If
Delay(100)
End If
Super.Render()
Return
End Method
Method OnSubmit(value:String)
Select stage
Case Stage_RequestingRole
If Left(value, 1).ToLower() = "r"
peer1 = TRKRakNetworkFactory.GetRakPeerInterface()
Print("Working as receiver")
Setup()
ElseIf Left(value, 1).ToLower() = "s"
peer2 = TRKRakNetworkFactory.GetRakPeerInterface()
Print("Working as sender")
Stage = Stage_RequestingIP
RequestValue("Server address", "Enter remote IP: ")
Else 'Act as both.
peer1 = TRKRakNetworkFactory.GetRakPeerInterface()
peer2 = TRKRakNetworkFactory.GetRakPeerInterface()
Text = "127.0.0.1"
Setup(Text)
End If
Case Stage_RequestingIP
If Value.Length = 0 Then
Text = "127.0.0.1" 'Added for default value.
Else
Text = value
End If
Setup(Text)
End Select
Return
End Method
Method Setup(IP:String = Null)
If peer1 Then
peer1.SetMaximumIncomingConnections(1) ;
Local socketDescriptor:TRKSocketDescriptor = New TRKSocketDescriptor.Create(10000)
peer1.SetMTUSize(1492)
peer1.Startup(1, 0, socketDescriptor)
peer1.SetSplitMessageProgressInterval(100) 'Get ID_DOWNLOAD_PROGRESS notifications
End If
If peer2 Then
socketDescriptor = New TRKSocketDescriptor.Create()
peer2.SetMTUSize(1492)
peer2.Startup(1, 0, socketDescriptor)
peer2.Connect(IP, 10000)
End If
Delay(500)
' Always apply the network simulator on two systems, never just one, with half the values on each.
' Otherwise the flow control gets confused.
' if peer1 then
' peer1.ApplyNetworkSimulator(128000, 0, 0)
' end if
' if peer2 then
' peer2.ApplyNetworkSimulator(128000, 0, 0)
' end if
End Method
End Type
Cool. Thanks.
I've tweaked it a little here and there, to store/compare the data as per the original. (and set it to use that full 2073900 bytes)
The "freezing" was because of calling GetData()[i] in the loop. Function calls are expensive ;-)
Working on the Byte Ptr itself solved the loooong delay!
:o)
.... trying to get my head around a design for the rakvoice mods...
Needs to be fairly flexible, and transparent for you lot to use :-p
The "freezing" was because of calling GetData()[i] in the loop. Function calls are expensive ;-)
Local pdata:Byte Ptr = packet.GetData()
woops! I knew they were more expensive...I wasn't aware they were
that much more costly though. Learn a new thing every day.
And ofcourse, the example is working great now.
.... trying to get my head around a design for the rakvoice mods...
Needs to be fairly flexible, and transparent for you lot to use :-p
Yeah, I think you turned that into a much larger scale for a project, but in a rank of coolness i'm sure it will be on the top.
I've committed the initial work. (BaH.RaknetVoice and BaH.RaknetVoiceFMOD).
The example is working here on Mac ;-)
However, it may not even compile (libspeex) yet on Windows... so be aware before trying it out.
I'll check the Win32 stuff tomorrow.
On Mac at least, you need to run two separate instances of the example. Doesn't work (rec+play) on
the same app. But I don't see that as being very important.
BlitzMax and audio chatting... very cool :-)
BlitzMax and audio chatting... very cool :-)
Indeed!
So much for getting a good nights rest, svn'ing now :)
Everything appears to compile fine.
Edit: But the fmod example for it doesn't appear to do anything. Win32. I haven't tried on mac to see if i'm doing something wrong or not yet.
Remember that one of the "clients" needs to start on a different "local port". If I start them both using the default, it doesn't work.
Once the two are running, (C)onnect with one of them using the appropriate details. If successful you should get a connect message appearing on each. After that, the audio should be working.
But I'll test Win32 shortly...
Wooo! Tested on XP with my Logitech USB headset, and it worked first time :-)
If you follow the method in the previous post, that should sort you out.
I'll give Linux a run this evening.
So, now that I've proved it does actually work, I'll have to finish the example, the Voice API, and see about implementing some of the other "audio adapters".
For PortAudio, I'll use Skid's Axe.PortAudio module.
Might even be able to get it working with Redi's maxmod2 ?
Hmm, thought I tried that. It's working now :) nice!
BlitzMax and audio chatting... very cool :-)
Hm.... I suppose it could be combined with ESCAPI (
http://www.blitzbasic.com/codearcs/codearcs.php?code=1899 ,
http://sol.gfxile.net/zip/escapi21.zip )
to whip up your own little webcam chat program.
Might even be able to get it working with Redi's maxmod2 ?
that would be neat.
@xlsior: What would be nice is cross-platform camera support! (OpenCV - hint hint)
Voice stuff now building on Linux... not tested yet, as *someone* left the headset at the office :-p
Any chance to get a rakvoicebass.mod next? :)
Possibly... if I can work out how to use the "push" interface... (rather than via the callbacks).
I think I'll be better coding it in C... so expect it not to be working properly for a while :-p
Just noticed RakNetRooms.mod from the svn. I had actually never touched the sample for raknet before but after reading the description i'm in awe..
I was actually just about to start working on a 'table' system for a game for users to join through a lobby, but apparently blitzmax is going to have a perfect library for just that. Top notch.
Just noticed RakNetRooms.mod from the svn.
It's not finished yet! :-p
I just needed to get what I'd done so far, committed. There's a lot to it... mostly callbacks... which I've yet to figure out the best implementation.
It's not finished yet!
I know =p just looking forward to it when it's finished.
Keep up the good work.
They're looking good so far.
I have just begun converting my work to your raknet module from jimons and all has been great, except for the bitstreams.
I noticed in comparison to jimons work, he had support for signed/unsigned integers with the bitstream class, and you were able to send a single bit (bool). It wouldn't be difficult to subtract for signed vs unsigned, but since this is blitzmax, and not c++...it is a bit more work for reading/writing on the users end to do that...what would you think of an additional argument on the read/write commands, for having a value for signed/unsigned? And is it possible to get a writebit function within the trkbitstream class?
Sorry if I missed anything for this, i'm still going through the module to understand the differences between the two for use with blitzmax better.
Got a quick question.
Does raknetrooms.mod, in it's current state, compile on linux for you?
Because if it does, there's something missing on my side :)
I get an error in /src/Rooms/ProfanityFilter.cpp:51: error: 'strlwr' was not declared in this scope.
Not that I use it for anything. But I'm lazy and check out all the bah.mods :-P
Does raknetrooms.mod, in it's current state, compile on linux for you?
raknetrooms is turning into a big pain. It would appear that it's only been tested on Windows, and at that, Visual Studio.... given all the errors I'm getting trying to compile it with MinGW..
However, I added an ifdef at the top (and actually re-wrote bits of ProfanityFilter.cpp) to assist in the compilation on Mac :
#ifdef __APPLE__
I think changing this to
#ifndef WIN32
will help compilation on Linux.
I'll test it properly on Linux it tonight. :-)
Does raknetrooms.mod, in it's current state, compile on linux for you?
Fix committed.
he had support for signed/unsigned integers with the bitstream class.
I've added support for UShort and UInt calls, as well as Bool and Bit functionality.
I also noticed, which I was referring to jimon's wrap (better to see what you mean), that he was passing Int to all the functions, and in the C++ glue accepting things such as char, short, etc. Very dangerous. I'm guessing noone on Mac ever tried that mod, as it would be very likely to nuke on a first call to a function with invalid parameters. (Much in the same way that for some reason you can't pass a Long back from C++ to BlitzMax - it is unreliable and can corrupt your data. But I use a workaround for that.)
Ahhh thank you!
that he was passing Int to all the functions, and in the C++ glue accepting things such as char, short, etc. Very dangerous.
Yeah i'm not sure what jimons focus was since none of us had any real chance to chat with him (no forum access?), but he may have just thrown it together to get rid of the dll requirement on a specific OS (likely windows).
But...that is just another reason why I was really anticipating your version of the module. Cheers
Just a few updates on the trkbitstream:
-Identifier 'WriteBool' not found (latest svn + built) [trkbitstream.writebool]
Some ideas, or missing features:
trkbitstream::
-GetLength() / GetWrittenBitcount()
-GetUnreadBitcount()
-GetReadPos()
And there appears to be no WriteCompressed<Vartype>(<val>) methods, but I might have overlooked something.
I have this :
Method WriteBool(value:Int)
As well as :
Method Write0()
Method Write1()
...
which I was sure I'd checked in...
<EDIT>Just updated my Win32 source and those methods appear there as I'd expect.
Some ideas, or missing features
I'll get onto those presently, as well as the WriteCompressed methods :-)
I have this :
Yeah they were showing up properly in blide, but writebool(<0/1>) wouldn't build for me, and I definitely built the mod lol. I'll try forcing rebuild or something and see how that works out.
I'm getting an error on CreateFromData. I'm trying to use bitstreams without using RPC, but i'm becoming stumped here.
Self.Reader is a trkbitstream
packet is a trkpacket
Self.packet = Interface.Receive()
If (Self.packet) Then
Local Data:Byte Ptr = packet.GetData()
Self.reader.CreateFromData(Data, packet.GetLength() , False)
In jimons source, he had:
RN_API BitStream * RN2_API RN_BitStreamCreateFromPacket(Packet *packet)
{
BitStream *b = new BitStream((unsigned char*)packet->data,packet->length,0);
return b;
}Which as far as I can tell, is exactly what i'm doing in my code with your version, but i'm receiving an error instead (unhandled memory excep.). I haven't a clue what's going wrong here =(
This is in the bigpacket example :
Local packet:TRKPacket = peer1.Receive()
While packet
If packet.GetData()[0] = ID_DOWNLOAD_PROGRESS Then
Local progressBS:TRKBitStream = TRKBitStream.CreateFromData(packet.GetData(), packet.GetLength(), False)
Note that CreateFromData is a function, if that makes any difference?
Thanks, i've gotten beyond that now, however something seems out of whack when I attempt to
readbyte from a bitstream =(
writeint/readint doesn't cause an error, but no value is returned (other then zero), but readbyte only gives me an
Unhandled Memory Exception ErrorIt appears to be linked with:
bool bmx_BitStream_ReadByte(RakNet::BitStream * stream, unsigned char * value) {
return stream->Read(value);
}
Nothing appears to happen with the value? not sure.
Ex:
Method Create_BitStream_From_Packet(Packet:TRKPacket)
Self.Reader = New TRKBitStream.CreateFromData(Self.packet.GetData(), Self.packet.GetLength(), False)
End Method
Method ReadByte:Byte()
Local Val:Byte
Self.Reader.ReadByte(Val)
Return Val
End Method
And I use this for writing the packets:
Method Create_BitStream(MessageID:Int, Compressed:Byte = 0)
Self.Writer = New TRKBitStream.CreateBitStream()
Writer.WriteByte((MessageID + ID_USER_PACKET_ENUM))
End Method
Method WriteByte(Value:Byte)
Self.Writer.WriteByte(Value)
End Method
The packet writes and recieves alright, but as for retreiving the data using the read commands - nada. Nothing appears to be wrong with write<datatype> methods though.