WeedDealer Posted January 20, 2013 Author Share Posted January 20, 2013 I've been messing around with the source tring to find out how it works.And i have seen that when u send data from client to server it use clsBuffer.If somebody can explain me why clsbuffers when it could send data as string or long to server I would be gratefull. Link to comment Share on other sites More sharing options...
Guest Posted January 20, 2013 Share Posted January 20, 2013 Basically the Buffer (cls is just a naming convention) packs all the data into a sendable format, writes how long each piece of data is and sends it off to the server. The server will then begin reading and unpacking it. The point of using the Buffer is that you can send lots of different data with different types e.g:```Buffer.WriteString Player.NameBuffer.WriteByte Player.AgeBuffer.WriteLong Player.XBuffer.WriteLong Player.Y```And the server is able to read this. It's a lot faster than sending data one by one and a lot more flexible. Link to comment Share on other sites More sharing options...
WeedDealer Posted January 20, 2013 Author Share Posted January 20, 2013 So the buffer its like a suitcase and with (.write"data") u put variables in it and (.toarray) is the entire datas from the buffer? Link to comment Share on other sites More sharing options...
Guest Posted January 20, 2013 Share Posted January 20, 2013 A typical packet looks like this:```Public Sub SendLogin(ByVal name As String, Pass As String)Dim buffer As clsBufferSet buffer = New clsBufferbuffer.WriteLong CLoginbuffer.WriteString namebuffer.WriteString PassSendData buffer.ToArray()Set buffer = NothingEnd Sub```Let's break it down.```Set Buffer = New clsBuffer```This is part of Object Orientated programming. It basically creates a new instance of the Buffer class so we can use it.```buffer.WriteLong CLoginbuffer.WriteString namebuffer.WriteString Pass```These lines add the various pieces of data to the Buffer. "CLogin" is a header that allows to server to know how to unpack the data and how to handle it (i.e. which sub to use).```SendData buffer.ToArray()Set buffer = Nothing```Finally we send all the packet data to the server. "Set Buffer = Nothing" simply removes the Buffer class we just used from memory. Link to comment Share on other sites More sharing options...
abhi2011 Posted January 20, 2013 Share Posted January 20, 2013 Yes. Link to comment Share on other sites More sharing options...
WeedDealer Posted January 20, 2013 Author Share Posted January 20, 2013 I just noticed that cls buffer is a different module.So its not something that is from standard vb6 is somethign that the designer of the game did.So i must see a tutorial for classes to undertsand buffers better? Link to comment Share on other sites More sharing options...
Guest Posted January 20, 2013 Share Posted January 20, 2013 The Buffer is a class. You should read up on Object Orientated programming. Link to comment Share on other sites More sharing options...
WeedDealer Posted January 20, 2013 Author Share Posted January 20, 2013 thank you for your quick answers.I shall read the OOP tutorial Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now