Hi,
I'm working on a peer to peer implementation but I can't get a RFC working.
Server connection -
//Create server
TNServerInstance.Start(port);
//Connect
TNManager.Connect("127.0.0.1", port);
Client connection -
//Connect to server
TNManager.Connect("127.0.0.1", port);
On the OnNetworkConnect method I check for success and call TNManager.JoinChannel(123, "TestScene");
Test scene loads and I have the following code attached to a game object to test a simple message.
using UnityEngine;
using System.Collections;
using TNet;
public class TNetWaitingArea : MonoBehaviour {
private string text = "text";
private string enterText = "message";
void OnGUI()
{
GUILayout
.BeginArea(new Rect
(0,
0, Screen
.width, Screen
.height)); GUILayout.Label(TNServerInstance.playerCount.ToString());
GUILayout.Label(text);
enterText = GUILayout.TextArea(enterText);
if (GUILayout.Button("Test"))
{
Debug.Log("Calling");
TNObject tbo
= GetComponent
(typeof(TNObject
)) as TNObject
; tbo.Send("TestMessage", Target.All, enterText);
}
GUILayout.EndArea();
}
[RFC] void TestMessage(string msg)
{
Debug.Log("Test called");
text = msg;
}
}
I can see that there are player connected on the server, I am getting no error messages but the TestMessage method is never called. Not even locally.
Been looking at this for a few hours now, pouring over the forums and code but getting nowhere fast. My guess is that I'm missunderstanding something fundamental like channels, or maybe I shouldn't be connecting to the server like a client in the same instance?
Any help greatfully received.