Creating Delegate Problem

Hi Guys,

I’m having some trouble with receiving a delegate.
I want to receive data on the UDP socket,

		FUdpSocketReceiver* mySocketReceiver;
		mySocketReceiver = new FUdpSocketReceiver(UdpSocket, FTimespan(0, 1, 0), TEXT("MyUDPSocketReceiver"));
		mySocketReceiver->OnDataReceived().BindRaw(this, &AMyUdpServer::OnDataReceived);

void AMyUdpServer::OnDataRevceived()
{
//Should be fired on data received??

}

I’m really stuck here, maybe i should declare the delegate or something i don’t know.
Just want it to fire the event when data is received^^

Now my compiler says:
Error 1 error C2664: ‘void TBaseDelegate<TTypeWrapper,const FArrayReaderPtr &,const FIPv4Endpoint &>::BindRaw<AMyUdpServer,>(UserClass ,void (__cdecl AMyUdpServer:: )(const FArrayReaderPtr &,const FIPv4Endpoint &) const)’ : cannot convert argument 2 from ‘void (__cdecl AMyUdpServer::* )(void)’ to ‘void (__cdecl AMyUdpServer::* )(const FArrayReaderPtr &,const FIPv4Endpoint &)’ C:\UnrealProjects\Server\Source\Server\MyUdpServer.cpp 250 1 Server

Any help would be appreciated, thanks in advance.

Cheers

B

the error message suggests your AMyUdpServer::OnDataRevceived does not have the correct arguments specified.

the UDP delegate has 2 arguments

  • FArrayReaderPtr - an array containing the data
  • FIPv4Endpoint - the senders ip.

i found this article very useful when working with UDP A new, community-hosted Unreal Engine Wiki - Announcements - Epic Developer Community Forums