OpenVidu on Unity

Hello,
I’m trying to implement OpenVidu with Unity, is there any way to do this?
Does OpenVidu have any SDK for unity?

Thanks

There is no official OpenVidu SDK for Unity.
But any client platform that has a modern WebRTC package should work fine with OpenVidu, if the RPC protocol is properly implemented.

Cheers.

I’m currently connecting to the API and then websocket connection, but when I do the first connection and send the first publishVideo call I get this error:

{“id”:5,“error”:{“code”:-1,“message”:“java.lang.NullPointerException:null”,“data”:“java.lang.NullPointerException\n\tat io.openvidu.server.kurento.core.KurentoParticipant.createPublishingEndpoint(KurentoParticipant.java:102)\n\tat io.openvidu.server.kurento.core.KurentoSessionManager.publishVideo(KurentoSessionManager.java:405)\n\tat io.openvidu.server.rpc.RpcHandler.publishVideo(RpcHandler.java:383)\n\tat io.openvidu.server.rpc.RpcHandler.handleRequest(RpcHandler.java:135)\n\tat org.kurento.jsonrpc.internal.JsonRpcHandlerManager.handleRequest(JsonRpcHandlerManager.java:142)\n\tat org.kurento.jsonrpc.internal.server.ProtocolManager$3.run(ProtocolManager.java:218)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base/java.lang.Thread.run(Thread.java:829)\n”},“jsonrpc”:“2.0”}

Make sure your participant has role PUBLISHER and not SUBSCRIBER.
Also make sure you are implementing the RPC protocol for the exact version of the OpenVidu deployment you are using.

I’m recieving this response after joinRoom:

Received: {
“id”: 3,
“result”: {
“id”: “con_TqjLN7oDLi”,
“finalUserId”: “42BC0A2CC7B6BA3D”,
“createdAt”: 1678190750655,
“metadata”: “{clientData: TestClient}”,
“value”: ,
“session”: “mareah-singapore-black-giraffe”,
“version”: “2.25.0”,
“mediaServer”: “kurento”,
“videoSimulcast”: false,
“role”: “SUBSCRIBER”,
“coturnIp”: “35.156.123.243”,
“coturnPort”: 3478,
“turnUsername”: “1678277150:sh97YR2k”,
“turnCredential”: “Oqn23RtnR4xDvCdz4FpmdwVSW7w=”,
“customIceServers”: [
{
“url”: “turn:35.156.123.243:3478”,
“username”: “1678277150:sh97YR2k”,
“credential”: “Oqn23RtnR4xDvCdz4FpmdwVSW7w=”
}
],
“sessionId”: “o60d9ulfs973a1qo0n2lrjqb37”
},
“jsonrpc”: “2.0”
}

How can I make the user PUBLISHER instead of SUBSCRIBER?

When creating a Connection from your application server, set the role to PUBLISHER: Application server - OpenVidu Docs

Use that Connection’s token to connect your user with RPC method joinRoom.

Just to clarify, when you say “When creating a Connection from your application server” that is coming from the api call that the client does or the server itself? Because on the client I am sending to the token api the session name and putting role PUBLISHER and I recieve this back:

  1. {“id”:“wss://aws.openvidu.assistance.immera.io?sessionId=mareah-singapore-black-giraffe&token=tok_LfdleuW5tJ4saj1C”,“token”:“wss://aws.openvidu.assistance.immera.io?sessionId=mareah-singapore-black-giraffe&token=tok_LfdleuW5tJ4saj1C”,“createdAt”:1678285979465,“connectionId”:“con_OJ0VR5MzT6”,“session”:“mareah-singapore-black-giraffe”,“data”:“”,“role”:“PUBLISHER”}

But when I connect with sockets using joinRoom sending this:

Sent: {“jsonrpc”: “2.0”,“method”: “joinRoom”,“params”: {“token”: “wss://aws.openvidu.assistance.immera.io?sessionId=mareah-singapore-black-giraffe&token=tok_LfdleuW5tJ4saj1C”,“session”: “mareah-singapore-black-giraffe”,“platform”: “Chrome 76.0.3809.132 on Linux 64-bit”,“metadata”: “{clientData: TestClient}”,“secret”: “xxxxxxxxxx”, “recorder”: false },“id”: 2 }

I recieve this:

Received: {“id”:2,“result”:{“id”:“con_KrFBIbXh1Y”,“finalUserId”:“59117852E0A2DB97”,“createdAt”:1678285980807,“metadata”:“{clientData: TestClient}”,“value”:[{“id”:“con_OLzhXJ2rZG”,“createdAt”:1678285898322,“metadata”:“{clientData: TestClient}”}],“session”:“mareah-singapore-black-giraffe”,“version”:“2.25.0”,“mediaServer”:“kurento”,“videoSimulcast”:false,“role”:“SUBSCRIBER”,“coturnIp”:“35.156.123.243”,“coturnPort”:3478,“turnUsername”:“1678372380:4OO3bC0u”,“turnCredential”:“hL+i1h5SwBoRC+Zhh6hyf2MjTSQ=”,“customIceServers”:[{“url”:“turn:35.156.123.243:3478”,“username”:“1678372380:4OO3bC0u”,“credential”:“hL+i1h5SwBoRC+Zhh6hyf2MjTSQ=”}],“sessionId”:“vrjo3s86a8u1djt90fpa3j5hg8”},“jsonrpc”:“2.0”}

SUBSCRIBER again. What is wrong here?

I sense some confusion in the basic concepts of how you are using the OpenVidu API. Please, carefully read this documentation page: Developing your video app - OpenVidu Docs.
Especially this section explaining the Workflow of an OpenVidu Session

The phrase “that is coming from the api call that the client does or the server itself?” makes me think that you are mixing the client-side and the server-side of your application. You must first create a Session and a Connection (with role PUBLISHER) from your application server, and then pass the token of the Connection to your application client. Only then you can use it to call the RPC joinRoom.