Facility Control

 View Only
  • 1.  Initiate message via listener as server

    Posted 09-22-2020 15:05

    Hello ross support,

    An short question: If i have listener as server, and i want to send via this listener message as bytes (and i don't want to use rosstalk) - how can I do that? 

    I mean something like this:

     

    var myListener = ogscript.getListenerById('myListener');

    mylistener.sendTCPAsBytes(ip,port,bytes_as_string);

     

    Is it possible?

    Thanks!



  • 2.  RE: Initiate message via listener as server

    Posted 09-22-2020 15:46

    Once you have the listener object, you should have access to these 3 commands:

    public abstract boolean writeAsBytes(String bytes) 
    public abstract boolean writeBytes(byte[] bytes) 
    public abstract boolean writeString(String bytes, boolean utf8) 

     

     


    #DashBoard


  • 3.  RE: Initiate message via listener as server

    Posted 09-22-2020 16:01

    So, in case the listener configured to just listen to port ( listen as server), to which adress it will send it?


    #DashBoard


  • 4.  RE: Initiate message via listener as server

    Posted 09-22-2020 16:08

    I know the workflow to putObject of connection on isConnectEvent() using 'this', but this can be done after the remote adress send something to me once. I need to initiate first time connection, and dont know how...


    #DashBoard


  • 5.  RE: Initiate message via listener as server

    Posted 09-23-2020 13:46

    Hi <x-zendesk-user data-user-name="alex samih-zade">378647052751</x-zendesk-user>

    When your listener is running as a server, it cannot initiate the connection - something needs to connect to it. This does not have to actually send a message to trigger your script - the act of connecting would be enough to trigger the connection event type. 

    In terms of what "this" is talking to when you are writing to the listener, you will have a "this" object for each established connection. For a client, there would only ever be a single active one. For a server, you  could potentially have many active connections (and many "this" objects that would be visible inside of the listener events).

    Hope this helps.

    James


    #DashBoard


  • 6.  RE: Initiate message via listener as server

    Posted 09-23-2020 13:51

    Hello James,

    Yes, this helps and clear, thanks!

     


    #DashBoard