Author Topic: TNGameServer modifying the callback message  (Read 5412 times)

hummada23

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 45
    • View Profile
TNGameServer modifying the callback message
« on: April 24, 2014, 06:35:00 AM »
Liking what I've seen of TNet so far, but I'm a complete noob with it and need a bit of help.

I'm trying to send a callback to a certain function which contains a value that the server has put there.

To do this, I'm modifying the ProcessForwardPacket method in the TNGameServer so that it modifies one of the parameters in the buffer, before it sends the buffer back to the caller via 'tp.SendTcpPacket(buffer)'. I can read the parameter I want from the buffer (a boolean), but I'm not sure how to change it with the BinaryWriter... How would I go about this?

If the answer is that I shouldn't be trying to modify a buffer- I should be creating a new one- then can someone please explain how to do this?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNGameServer modifying the callback message
« Reply #1 on: April 25, 2014, 10:36:47 AM »
Send a callback to a function put by a server? What now? First, server is just a program that echoes packets. Do you mean host? If so, what do you mean by sending a callback to it? You can only send RFCs. Sending an RFC marked as saved will update the existing one.

I am also completely lost as to what you're trying to do with the server modifications or -- more importantly -- why this is needed.

hummada23

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 45
    • View Profile
Re: TNGameServer modifying the callback message
« Reply #2 on: April 25, 2014, 09:09:23 PM »
Ultimately what I want is for the server to read a particular kind of packet and validate it (which it's doing), and then instead of echoing that packet to clients I want to create and send a different packet. The way I was trying to do this was by modifying the GameServer class itself. It seems like this isn't in line with how TNet has been designed, but it seems like an easy way to make the server authoritative.

So, could I then send an RFC from the GameServer class? If this is not possible, I'm guessing I need a 'host' client to send the RFC, in which case I'll just auto instantiate this host on the server when it starts, and then make sure all other client packets are directed to this host.

Do you think this is a reasonable way to achieve what I'm going for? Should I be trying something else instead?

Thanks

hummada23

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 45
    • View Profile
Re: TNGameServer modifying the callback message
« Reply #3 on: April 26, 2014, 12:54:21 AM »
I was able to achieve what I wanted by creating a new packet in the ProcessForwardPacket method in the GameServer class (using a BinaryWriter), and then returning this packet to all clients (instead of echoing the original request to all clients). This allows me to do server-side validation of packets and to correct packets that contain mistakes (unintentional or otherwise).

It seems to run fine, but please let me know if you think there's a better way to do this.

Thanks
 

 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: TNGameServer modifying the callback message
« Reply #4 on: April 26, 2014, 03:29:58 PM »
Yup, that's fine. Just keep in mind that the server has no concept of RFCs. It merely forwards packets.