To reduce Bandwidth by using a byte array system. May cause the server to use a little more CPU like .2 per every 300 players but it would drastically reduce bandwidth so then you would not need to worry about stuff being sent back and forth XD.
this is an example in vb6 but can be written over to java just would have to change a few variables.
Private Buffer() As Byte ' Our byte array to hold all data
this is for writing a single -255 to 255 data variable into the byte array.
- Code: Select all
Public Sub WriteByte(ByVal nByte As Byte)
Select Case WriteHead > BufferSize
Case True
Allocate 1
End Select
Buffer(WriteHead) = nByte
WriteHead = WriteHead + 1
End Sub
this is fr writing a preallocated amount to the byte array.
- Code: Select all
Public Sub WriteBytes(ByRef nByte() As Byte)
Dim nLength As Long
nLength = (UBound(nByte) - LBound(nByte)) + 1
Select Case WriteHead + nLength - 1 > BufferSize
Case True
Allo
this is used to read the Data from the byte.
- Code: Select all
Public Function ReadByte(Optional MoveReadHead As Boolean = True) As Long
Select Case ReadHead > BufferSize
Case True
Exit Function
End Select
ReadByte = Buffer(ReadHead)
Select Case MoveReadHead
Case True
ReadHead = ReadHead + 1
End Select
End Function
this is to read the prelocated data from the byte array.
- Code: Select all
Public Function ReadBytes(ByVal nLength As Long, Optional MoveReadHead As Boolean = True) As Byte()
Dim Data() As Byte
Select Case ReadHead + nLength - 1 > BufferSize
Case True
Exit Function
End Select
ReDim Data(nLength) As Byte
CopyMemory Data(0), Buffer(ReadHead), nLength
Select Case MoveReadHead
Case True
ReadHead = ReadHead + nLength
End Select
ReadBytes = Data
End Function