For fun, started asking ChapGPT to write scripts for odd use cases in various languages. What are your thoughts?
With Lua scripting, write a Jitsi Meet script
-- Import the Lua socket library
local socket = require "socket"
-- Set the room name to join
local roomName = "example-room"
-- Create a new HTTP request to join the Jitsi Meet room
local request = "GET /" .. roomName .. " HTTP/1.0\r\n\r\n"
-- Open a socket connection to the Jitsi Meet server
local host = "meet.jit.si"
local port = 80
local client = socket.tcp()
client:connect(host, port)
-- Send the HTTP request to join the room
client:send(request)
-- Read the server response to the request
local response = client:receive("*a")
-- Close the socket connection
client:close()
-- Display an alert when the user joins the room
function onConferenceJoined(conference)
print("Joined conference: " .. conference)
alert("You have joined the conference.")
end
Write me a Unity script that implements Jitsi
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using JitsiMeet;
public class JitsiMeetController : MonoBehaviour
{
private JitsiMeetView jitsiMeetView;
private bool isVideoMuted = false;
private bool isAudioMuted = false;
private string roomName = "example-room";
private string serverUrl = "https://meet.jit.si";
void Start()
{
// Create a new Jitsi Meet view
jitsiMeetView = gameObject.AddComponent<JitsiMeetView>();
// Set the server URL and room name
jitsiMeetView.ServerURL = serverUrl;
jitsiMeetView.RoomName = roomName;
// Register event listeners for Jitsi Meet events
jitsiMeetView.AddListener(JitsiMeetView.Events.ConferenceJoined, OnConferenceJoined);
jitsiMeetView.AddListener(JitsiMeetView.Events.ConferenceLeft, OnConferenceLeft);
jitsiMeetView.AddListener(JitsiMeetView.Events.ParticipantJoined, OnParticipantJoined);
jitsiMeetView.AddListener(JitsiMeetView.Events.ParticipantLeft, OnParticipantLeft);
// Start the Jitsi Meet conference
jitsiMeetView.JoinConference();
}
void Update()
{
// Toggle video mute status with the V key
if (Input.GetKeyDown(KeyCode.V))
{
isVideoMuted = !isVideoMuted;
jitsiMeetView.SetVideoMuted(isVideoMuted);
}
// Toggle audio mute status with the A key
if (Input.GetKeyDown(KeyCode.A))
{
isAudioMuted = !isAudioMuted;
jitsiMeetView.SetAudioMuted(isAudioMuted);
}
}
void OnConferenceJoined(Hashtable data)
{
Debug.Log("Joined conference: " + data["roomName"]);
}
void OnConferenceLeft(Hashtable data)
{
Debug.Log("Left conference: " + data["roomName"]);
}
void OnParticipantJoined(Hashtable data)
{
Debug.Log("Participant joined: " + data["participantId"]);
}
void OnParticipantLeft(Hashtable data)
{
Debug.Log("Participant left: " + data["participantId"]);
}
}