public void Initialize(string id) { LNSClientParameters clientParameters = new LNSClientParameters(id, System.Environment.UserName); LNSConnectSettings settings = new LNSConnectSettings(); settings.gameKey = "com.hybriona.multiplayertest"; settings.gameVersion = Application.version; if (connectToLocalServer) { settings.serverIp = "127.0.0.1"; } else { settings.serverIp = "45.55.33.88"; } settings.serverPort = 10002; settings.serverSecurityKey = serverKey; //settings.serverIp = "192.168.0.100"; connector = new LNSConnector(clientParameters, settings, this); if (writer == null) { writer = new LNSWriter(); } writer.Reset(); connector.onPlayerConnected = OnPlayerConnected; connector.onPlayerDisconnected = OnPlayerDisconnected; connector.onMasterClientUpdated += (LNSClient client) => { Debug.Log("Masterclient changed to " + client.id); }; }
public FakeClient(string ip, int port, string id) { LNSClientParameters clientParameters = new LNSClientParameters(id, null); LNSConnectSettings connectSettings = new LNSConnectSettings(); connectSettings.serverIp = ip; connectSettings.serverPort = port; connectSettings.serverSecurityKey = "iamatestserver"; connectSettings.gameKey = "hybriona.ccutest"; writer = new LNSWriter(); connector = new LNSConnector(clientParameters, connectSettings, this); connector.onConnected += () => { connector.JoinRoomOrCreateIfNotExist("test", 10000); }; connector.Connect(); }
public void StartProcess(string id) { clonePrefab.SetActive(false); writer = new LNSWriter(); player.GetComponent <SphereGizmos>().radius = searchExtends; if (name == "Client") { id = "Client"; player.localPosition = Vector3.zero; } StartCoroutine(RandomMovement()); player.localPosition = new Vector3(Random.Range(-1f, 1f), 0, Random.Range(-1f, 1f)) * mapSize * .5f; LNSClientParameters clientParameters = new LNSClientParameters(id, gameObject.name); LNSConnectSettings connectSettings = new LNSConnectSettings(); if (useLive) { connectSettings.serverIp = liveip; } else { connectSettings.serverIp = ip; } connectSettings.serverPort = port; connectSettings.serverSecurityKey = "demokey"; connectSettings.gameKey = "hybriona.quadtreetest"; if (!useLive) { connectSettings.serverSecurityKey = "demokey"; } connector = new LNSConnector(clientParameters, connectSettings, this); connector.onConnected = () => { LNSCreateRoomParameters roomParameters = new LNSCreateRoomParameters(); roomParameters.maxPlayers = 100; roomParameters.isQuadTreeAllowed = true; //roomParameters.idleLife = 60 * 24; roomParameters.EnableQuadTreeCellOptimization(Vector2.zero, new Vector2(2000, 2000)); connector.CreateRoom("default", roomParameters); }; connector.onFailedToConnect = (CONNECTION_FAILURE_CODE code) => { Debug.LogError(name + " - " + code); }; connector.onDisconnectedFromRoom = () => { Debug.LogError(name + " - onDisconnectedFromRoom"); }; connector.onDisconnected = () => { Debug.LogError(name + " - onDisconnectedFromServer"); }; connector.onRoomCreateFailed = (ROOM_FAILURE_CODE code) => { Debug.LogError(name + " - " + code); if (code == ROOM_FAILURE_CODE.ROOM_ALREADY_EXIST) { connector.JoinRoom("default"); } }; connector.onRoomJoined = () => { Debug.Log(name + " on room joined"); }; connector.onRoomJoinFailed = (ROOM_FAILURE_CODE code) => { Debug.LogError(name + " - " + code); }; connector.Connect(); }