•Here explain how to connect to server.
•Please do dll_import firstly then try to connect server.
•In Unity3D, you cannot declare so create from class that inherit MonoBehaviour.
•Firstly create Nettention.Proud.NetClient
Example
public class Client : MonoBehaviour { Nettention.Proud.NetClient netClient = new Nettention.Proud.NetClient(); ...
And then, initialize Nettention.Proud.NetClient at Start function (Unity3D event). Please refer to 9. Include PIDL compiled result
for event handling or etc.
Example
void Start () { //Set Event delegate of netclient. netClient.JoinServerCompleteHandler = OnJoinServerComplete; ... //Set delegate that handling stub. s2cStub.NotifyLocalHeroViewersGroupID = NotifyLocalHeroViewersGroupID; ... //Attach proxy,stub to client. netClient.AttachProxy(c2cProxy); ... }
Initialize Nettention.Proud.NetConnectionParam and call Nettention.Proud.NetClient.Connect()
Example
Nettention.Proud.NetConnectionParam param = new Nettention.Proud.NetConnectionParam(); //Synchronize protocolVersion. param.protocolVersion.Set(new System.Guid("{0x7b7e9c20,0x309c,0x4364,{0xb4,0x9c,0xc6,0xc,0xcd,0x25,0xaf,0xa0}}")); //Set server port up param.serverPort = 32222; //Set server IP address upparam.serverIP = serverAddr; netClient.Connect(param);
Call NetClient.FrameMove where the function ,like Update, called ( caution ! If the FrameMove were not called , Events would not been treated !)
void Update()
{
...
netClient.FrameMove();
}
Now delegate which set to Nettention.Proud.NetClient.JoinServerCompleteHandler has done to Connect or not. Please refer to 13. Set RMI function and Event
then set up event.