how to send data from client to client?

I’m trying to send data directly to other specific client and not all clients without interrupting the server’s bandwidth.

and here’s how I’m trying to do it atm.

Sending RPC failed because 'P2PMessage' parameter 0 (UnityEngine.NetworkMessageInfo) is not supported.
UnityEngine.NetworkView:RPC(String, RPCMode, Object[])
Server:OnGUI() (at Assets/Networking/Server.cs:29)

Server Script:

private NetworkMessageInfo Info1;
private NetworkMessageInfo Info2;




	void OnGUI (){
		
		if (Network.peerType == NetworkPeerType.Disconnected){
			if (GUILayout.Button("Start Server")){
				Network.InitializeServer(10, Port);
			}
		}
		else {
			GUILayout.Label("Server");
			GUILayout.Label("Connections: " + Network.connections.Length);
			if (GUILayout.Button("Logout")){
				Network.Disconnect(5);
			}
		}
		if (GUILayout.Button("send infos")){
			networkView.RPC("P2PMessage", RPCMode.All, Info1, Info2);
		}
	}





[RPC]
void Register (string UserName, string Password, NetworkMessageInfo Info){
	Info1 = Info;
}
[RPC]
void LogIn (string UserName, string Password, NetworkMessageInfo Info){
	Info2 = Info;
}

Client Full Script:

using UnityEngine;
using System.Collections;

public class Client : MonoBehaviour {
	public GameObject Planet;
	public string IP = "31.15.149.40";
	public int Port = 25001;
	
	private string UserName = "Username";//||Email";
	private string UserPass = "";
	
	string type = "";
	bool works = false;
	bool P2P = false;
	NetworkMessageInfo Info1;
	NetworkMessageInfo Info2;
//	int MyNetworkInt = 0;
	
	void Start (){
		Network.Connect(IP, Port);
	}
	
	void OnGUI (){
		if (Network.peerType == NetworkPeerType.Disconnected){
			if (GUILayout.Button("Reconnect")){
				Network.Connect(IP, Port);
			}
		}
		
		// enter username
		GUILayout.BeginHorizontal();
			GUILayout.Label("User Name");
			UserName = GUILayout.TextField(UserName, GUILayout.MinWidth(50));
		GUILayout.EndHorizontal();
		
		// enter password
		GUILayout.BeginHorizontal();
			GUILayout.Label("Password");
			UserPass = GUILayout.PasswordField(UserPass,'*', GUILayout.MinWidth(30));
			GUILayout.Label("" + UserPass.Length);
		GUILayout.EndHorizontal();
		
		// login || register
		
		if (! (Network.peerType == NetworkPeerType.Disconnected)) {
			GUILayout.BeginHorizontal();
				if (GUILayout.Button("Login")){
					networkView.RPC("LogIn", RPCMode.Server, UserName, UserPass);
				}
				if (GUILayout.Button("Register")){
					networkView.RPC("Register", RPCMode.Server, UserName, UserPass);
				}
			GUILayout.EndHorizontal();
			GUILayout.Label(type + works);
			GUILayout.Label("P2P is " + P2P);
			if (GUILayout.Button("Send true To Client 1 and mark mine false") ){
				P2P = false;
				networkView.RPC("P2Pmessage", Info1.sender, true);
			}
			if (GUILayout.Button("Send true To Client 2 and mark mine false") ){
				P2P = false;
				networkView.RPC("P2Pmessage", Info2.sender, true);
			}
		}
	}

	

	[RPC]
	void P2PMessage (NetworkMessageInfo inf1, NetworkMessageInfo inf2){
		Info1 = inf1;
		Info2 = inf2;
	}
	[RPC]
	void ReturnTF (string tip, bool TF){
		works = TF;
		type = tip;
	}
}

I gave client full because I think all info is important, …

thanks in advance.

RPC calls accept only a few parameter : int, float, string, NetworkPlayer, NetworkViewID, Vector3, Quaternion.

It accepts NetworkMessageInfo only for the last argument, and it contains informations about who sent the call.

Have a look at the doc here.

You also send a boolean (lign 58 and 62), but your method P2PMessage does not have any boolean arg.

You should have :

[RPC]
void P2PMessage (boolean myBool, NetworkMessageInfo info)
{
   ...
}

You may need another argument to know if it is client 1 or 2 to valuate Info1 or Info2 (It depends on what you really want to do with this information…)