Author Topic: TCP external modules and Engine::dispatch  (Read 7247 times)

andr04

  • Newbie
  • *
  • Posts: 18
    • View Profile
TCP external modules and Engine::dispatch
« on: May 09, 2017, 07:37:37 AM »
I have the following function which returns CallEndpoint by channel id:
Code: [Select]
static CallEndpoint* locateChan(const String& id, bool peer = false)
{
    if (id.null())
return 0;
    Message m("chan.locate");
    m.addParam("id",id);
    if (!Engine::dispatch(m))
return 0;
    CallEndpoint* ce = static_cast<CallEndpoint*>(m.userObject(YATOM("CallEndpoint")));
    if (!ce)
return 0;
    return peer ? ce->getPeer() : ce;
}

This code is used from ExtModReceiver::processLine as follows. And this works if external module is a pipe script, but doesn't work if it a TCP socket. I tried to debug it without success: Engine::dispatch doesn't work.

The difference which I've found is TCP extmodule starts from an additional thread of ExtListener which is a server for processing incoming connections (it's true approach). Can this broke Engine::dispatch? Or may be other reasons?

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: TCP external modules and Engine::dispatch
« Reply #1 on: May 10, 2017, 01:02:42 AM »
Can you tell what happens?
- channel id is empty: add debug to see it
- chan.locate fails: check message with sniffer enabled
- chan.locate returns NULL or a non CallEndpoint descendant: NULL may be checked with message sniffer
- returned CallEndpoint has no peer and peer was requested: add debug to see it