Tasharen Entertainment Forum

Support => TNet 3 Support => Topic started by: zipper on November 07, 2013, 01:22:16 AM

Title: Simple One Way Communication
Post by: zipper on November 07, 2013, 01:22:16 AM
Hi,

I have a project that is split between a UI application on a touch display (UI.exe), and a 3D content program on a huge wall display (3d.exe).

I just need to send one way commands from UI.exe to 3d.exe.

Since i love NGUI, i purchased Tnet to do it, but i am kinda stuck, and under a heavy deadline (work as usual...).

Would you be so kind as to give just a quick example of sending a simple color change command initiated by a mouse click from UI.exe that changes the color of anything in 3d.exe?

One example and i can get it from there.

Thanks so much,
zipper
Title: Re: Simple One Way Communication
Post by: ArenMook on November 07, 2013, 05:08:36 AM
If they are on the same LAN, then it's actually ridiculously easy. Just use the BroadcastToLAN functionality (you don't even need to connect)
  1. using UnityEngine;
  2. using TNet;
  3.  
  4. public class Test : TNBehaviour
  5. {
  6.         void Start ()
  7.         {
  8.                 TNManager.StartUDP(5128);
  9.         }
  10.  
  11.         void OnClick ()
  12.         {
  13.                 tno.BroadcastToLAN(5128, "SetColor", Color.red);
  14.         }
  15.  
  16.         [RFC]
  17.         void SetColor (Color c)
  18.         {
  19.                 Debug.Log("My color is now " + c);
  20.         }
  21. }
Title: Re: Simple One Way Communication
Post by: zipper on November 07, 2013, 09:27:58 AM
Super!

Thanks Aren for your quick response!

I really appreciate it! - You are a lifesaver :)
Title: Re: Simple One Way Communication
Post by: zipper on November 08, 2013, 05:19:45 AM
One more question  ;D

How would i make this work if both applications are running on the same machine? From what i understand, i can't bind a udp port with one .exe and have another .exe listen to the same port on the same machine. Is this correct?

Sorry for the noobness :(
Title: Re: Simple One Way Communication
Post by: ArenMook on November 08, 2013, 10:57:33 AM
You can't use broadcast to LAN for two instances running on the same machine. You need to use different machines, or establish a connection from one to another first, then use regular RFCs.