public void OnData(int connectionId, int channelId, byte key, byte[] data, byte error) { CircleVRPacketType type = (CircleVRPacketType)key; if (!connected) { if (type == CircleVRPacketType.Error) { CircleVRError cvError = JsonUtility.FromJson <CircleVRError>(CircleVRNetwork.ByteToString(data)); Debug.Log("[INFO] Error : " + cvError.type.ToString()); if (cvError.type == CircleVRErrorType.AlreadyHasUserID || cvError.type == CircleVRErrorType.NotFoundUserIDInPairs) { connecting = false; } return; } if (type == CircleVRPacketType.HostInfo) { Debug.Log("[INFO] Circle VR Connect Succeed!"); HostInfo hostInfo = JsonUtility.FromJson <HostInfo>(CircleVRNetwork.ByteToString(data)); CircleVRDisplay.InitBarrier(hostInfo.safetyBarrierRadius, hostInfo.showBarrier); connected = true; connecting = false; CircleVRNetwork.Send(CircleVRPacketType.RequestServerContentInfo, connectionId, CircleVRNetwork.reliableChannel); return; } } }
private CircleVRHost CreateHost(Configuration config) { CircleVRDisplay.InitBarrier(config.circlevr.safetyBarrierRadius, config.circlevr.showBarrier); CircleVRHost host = DontDestroyInstantiate("Host", Vector3.zero, Quaternion.identity).AddComponent <CircleVRHost>(); host.Init(config); return(host); }