Author Topic: EndSend Exepctions - mBuffer is null  (Read 2923 times)

Phantom75

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
EndSend Exepctions - mBuffer is null
« on: September 16, 2013, 02:17:13 PM »
Hi

I'm getting Exceptions in EndSend() - mBuffer is null when it's not supposed to be.
The calling code is:
BinaryWriter writer = BeginSend(Packet.ResponseNextWaypoint);
            writer.Write(e.Guid);
            writer.Write(e.WayPointNr);
            writer.Write(e.X);
            writer.Write(e.Y);
            writer.Write(e.Z);
            writer.Write(e.Speed);
            EndSend(true, c, null);

The Channcel C at that time did not have any subscribers.



Cheers

Martin

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: EndSend Exepctions - mBuffer is null
« Reply #1 on: September 16, 2013, 02:24:59 PM »
If the channel has no subscribers, don't try to send anything to it. Responses are generally sent to a submitted client request. How can there be a request for a channel if there is no one in the channel?

Phantom75

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: EndSend Exepctions - mBuffer is null
« Reply #2 on: September 17, 2013, 01:36:39 AM »
It's NPC's that update their position to all Players in the game. So I thought I need to subscribe them all to a channel. Did I get that wrong then?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: EndSend Exepctions - mBuffer is null
« Reply #3 on: September 17, 2013, 01:59:00 PM »
Er... what? Did you add some server-side AI logic into TNet? Because by default, TNet merely facilitates a way to echo packets between connected clients, and any and all AI logic would be done on the client (generally the channel's host, or the object's owner). Since it's done by a client, no client means no logic, and nothing to send.

Phantom75

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: EndSend Exepctions - mBuffer is null
« Reply #4 on: September 17, 2013, 10:00:23 PM »
Welll.... yes. It's a mmorpg and there, if you put logic into the client, they game isn't yours anymore. So yes, I enhanced the TNet Server with database logic to load data and do the AI logic. Sorry, if I haven't used TNet in a way it's not meant to be used.... :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: EndSend Exepctions - mBuffer is null
« Reply #5 on: September 18, 2013, 01:18:25 PM »
Alright, so all you're missing is just a simple check -- is there anyone in the channel? No? Then don't send. :P