However I'm struggling with ReceiveData and the EventHandler.OnReceiveData:
When you receive this message it means that there is new data available in
the connection specified by "ID", and that you should call ReceiveData()
now to read this data from the network buffer. (V5.0)
If I have the ReceiveData() call in the onconnect event I can read data coming in on the server port.
However, I would like the ReceiveData() call in the OnReceiveData event. But it gives me an error that CLIENTID table is not defined.
If I change router$,count,done = ReceiveData(msg.CLIENTID, #RECEIVEALL) to router$ = ReceiveData(1, #RECEIVEALL)
It tells me server 1 is invalid.
Any pointers would be appreciated.
Here is a cut down snippet
Code: Select all
CreateServer(1,10060)
Function p_ConnectFunc(msg)
Switch(msg.action)
Case "OnConnect":
DebugPrint("Connection Established ",msg.CLIENTID)
;router$,count,done = ReceiveData(msg.CLIENTID, #RECEIVEALL)
;DebugPrint(router$)
EndSwitch
EndFunction
Function p_ReceiveFunc(msg)
Switch(msg.action)
Case "OnReceiveData":
DebugPrint("Receive Data ")
router$,count,done = ReceiveData(msg.CLIENTID, #RECEIVEALL)
DebugPrint (router$)
EndSwitch
EndFunction
InstallEventHandler({OnConnect = p_ConnectFunc, OnReceiveData = p_ReceiveFunc})
Repeat
WaitEvent
Forever
CloseServer(1)