Code:
Private Sub DataReceived(ByVal id As String, ByVal idata As String, _
Optional ByVal EPHelperLocal As Integer = 0, _
Optional ByVal EPHelperRemote As Integer = 0) _
Handles HOST.DataReceived
' ID = string containing: ipaddress and sentfrom port format of "XXX.XXX.XXX.XXX:1234"
Dim cName As String
Dim ChatString As String
Try
ChatString = idata
If InStr(ChatString, NetworkHeader.ReceiveOrSendChat) Then
cName = GetClientNicknameFromString(id)
ConnectionHistory = ConnectionHistory + " :: " + cName + ":" + id + ":" + Now.ToShortTimeString + " "
ChatString = NetworkHeader.ReceiveOrSendChat & cName & ": " & RemoveLead(idata)
BroadcastToAll(ChatString)
End If
' Section A
If InStr(ChatString, NetworkHeader.RequestConnection) Then
msg(" New player requesting connection: " + ChatString + " | " + id, ConsoleColor.DarkBlue, ConsoleColor.Green)
createnewclient(id, idata)
'PSUDOCODE:
SendDataToClient(" HOLEPUNCH TEST " & EPHelperLocalPort.Tostring, TO ClientIP:EPHelperLocalPort)
SendDataToClient(" HOLEPUNCH TEST " & EPHelperLocalPort.Tostring, TO ClientIP:EPHelperRemotePort)
'Client then bounces back port received in a new message.
'END PSUDOCODE
End If
'Section B
If InStr(ChatString, NetworkHeader.HolePunchReply) Then
msg(" New player Setting HolePunchInfo: " + ChatString + " | " + id, ConsoleColor.DarkBlue, ConsoleColor.Green)
createnewclient(id, idata)
'PSUDOCODE:
HolePunchPort = Val(Port Number Echoed back from Client [see Section A] )
'edit the data of the client with the new port info received in the data string from Section A
EditNewClient(id,HolePunchPort)
'END PSUDOCODE
End If
'Section OtherCrap
If InStr(ChatString, NetworkHeader.RequestTableUpdate) Then
UpdateSingleClientTable(id)
msg("NetworkHeader.RequestTableUpdate = Yes")
End If
If InStr(ChatString, NetworkHeader.IWantToShoot) Then
MakeShoot(id, idata)
End If
'double check those below this line.
If InStr(ChatString, NetworkHeader.PlayerLocationUpdate) Then
' msg(">> updating location")
updateClientLocation(id, ChatString)
End If
If InStr(ChatString, NetworkHeader.PlayerRotationUpdate) Then
' msg(">> updating rotation")
updateClientRotation(id, ChatString)
End If
If InStr(ChatString, NetworkHeader.Pong) Then
UpdatePingInfo(id, ChatString)
End If
If InStr(ChatString, NetworkHeader.ClientReady) Then
'msg("Received client ready")
MarkPlayerReady(id, ChatString)
End If
Catch ex As Exception
msg("error in DataReceived:" + ex.ToString)
End Try
End Sub
In relation to the routine in the previous post, then this should hole punch it.
Sound right? i know there are errors but i'm not sure what they are.
I'm bouncing ideas off anyone reading this because it takes me so long to get an internet test going with one of my WAN testers.
So any suggestions/feedback you have would be appreciated.