Author Topic: UDPForwarder Possible Change Destination  (Read 6144 times)

DeepSea

  • Not-a-newbie
  • *
  • Posts: 23
  • Karma: 1
    • View Profile
UDPForwarder Possible Change Destination
« on: July 01, 2009, 11:03:08 PM »
Hi,

I am designing a gateserver,which in general does 2 tasks:

1.let the client connect to it and no need to reconnect to other servers when the client needs to.(remains the same connection from beginning to the end)

2.forwarding packets based on phases(login phase,switch zone etc.)

After digging into the udpForwarder class,I found it lacks a feature that can change the forwarding destination address,so that I can do the following code

(pseudo code)

switch(packet->data[0])
{
...........
case ID_SWITCH_ZONE:
     udpForwarder.changeForwardingDestination(packet->systemAddress,server2Addr);
    //from now on ,this client will talk to server2
case ID_LOGIN_REQUEST:
    udpForwarder.changeForwardingDestination(packet->systemAddress,loginServerAddr);
    //All the packets now will be forwarded to LoginServer
   //In both cases the srcToDestPort and destToSourcePort should remain the same after changing the
  //destination host addr.
}

is it possible to do it?
If it is,how can I tell the new destination server to accept the "newly" connected system without let the client call "rakpeer->connect".

Thanks in Advance.

DeepSea
« Last Edit: July 01, 2009, 11:06:54 PM by DeepSea »

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: UDPForwarder Possible Change Destination
« Reply #1 on: July 02, 2009, 09:41:03 AM »
Just use StopForwarding followed by StartForwarding.

DeepSea

  • Not-a-newbie
  • *
  • Posts: 23
  • Karma: 1
    • View Profile
Re: UDPForwarder Possible Change Destination
« Reply #2 on: July 02, 2009, 08:01:17 PM »
But the srcToDestPort and destToSourcePort will be changed ,which means the client has to reconnect to the gateserver,is there a "silent" way to do it like auto routing the packets?

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: UDPForwarder Possible Change Destination
« Reply #3 on: July 02, 2009, 09:53:08 PM »
You specify the port. No reason it has to change. And the forwarder is connectionless

DeepSea

  • Not-a-newbie
  • *
  • Posts: 23
  • Karma: 1
    • View Profile
Re: UDPForwarder Possible Change Destination
« Reply #4 on: July 02, 2009, 10:45:47 PM »
got your idea..thanks

1 more question:
how can i add a connection in the server side so that the server and client can communicate (let the client being "online")without let the client call peer->connect()
i

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: UDPForwarder Possible Change Destination
« Reply #5 on: July 02, 2009, 10:53:42 PM »
You can send raw UDP messages with SendOutOfBand(), although I don't recommend it.