Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Packet Checker
#1
Difficulty: 1/5

Introduction
Has it ever happened to you, that you send packets that does not exist? Well, if you add this, you will be warned when a packet is sent that does not have a reciever.


Tutorial Start: Client Side (IF)
First, make sure that all the If (LCase(Parse(0)) in Sub HandleData has a Exit Sub before the End if. Ex)
Code:
' ::::::::::::::::::::
    ' :: Weather packet ::
    ' ::::::::::::::::::::
    If (LCase(Parse(0)) = "weather") Then
        GameWeather = Val(Parse(1))
        [b]Exit Sub[/b]
    End If
After that, at the bottom of of Sub HandleData, add this:
Code:
Call SendData("PacketError" & SEP_CHAR & Parse(0) & SEP_CHAR & END_CHAR)

Server Side
Now make a listbox on the server and name it lstDebugPacket. Now anywere in Sub HandleData, add:
Code:
' :::::::::::::::::::::::::::
    ' :: Type the packet error ::
    ' :::::::::::::::::::::::::::
    If LCase(Parse(0)) = "PacketError" Then
        frmServer.lstDebugPacket.AddItem "Server-Client" & Parse(1) & " | " & date & " | " & time
    End If

Now, make sure all If LCase(Parse(0)) in Sub HandleData has a ExitSub, as you did for the Client.
And at the bottom add:
Code:
frmServer.lstDebugPacket.AddItem "Client-Server" & Parse(1) & " | " & date & " | " & time

Tutorial Start: Client Side (Select Case)
So now if you use select case, you use pretty much the same system, but at the bottom of Sub HandleData, instead of adding that line of code, you add this before it:
Code:
Case Else

Thats it! Now when a packet that does not exist in your game/engine is found. It will be typed in the listbox, so you easily can debug and find it Smile
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)