Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.Net.Security;
- using System.Security.Cryptography.X509Certificates;
- using UnityEngine;
- using TwitchLib;
- using TwitchLib.Events.Client;
- using TwitchLib.Models.Client;
- public class GamerTwitchLib : MonoBehaviour {
- private void Start()
- {
- ServicePointManager.ServerCertificateValidationCallback = CertificateValidationMonoFix;
- string userName = "GamerBOT28";
- string clientID = "aav9foqxbflb676m8rkjqt7trlj5gk";
- string accessToken = "obl3i78b2mlvqc6brg50pnb3t7yh80";
- string channelToJoin = "GamerRO28";
- ConnectionCredentials credentials = new ConnectionCredentials(userName, accessToken);
- TwitchAPI.Settings.ClientId = clientID;
- TwitchAPI.Settings.AccessToken = accessToken;
- TwitchClient client = new TwitchClient(credentials, channelToJoin);
- client.OnJoinedChannel += ClientOnJoinedChannel;
- client.Connect();
- }
- private void ClientOnJoinedChannel(object sender, OnJoinedChannelArgs onJoinedChannelArgs)
- {
- Debug.Log($"User {onJoinedChannelArgs.Username} joined the channel!");
- }
- public bool CertificateValidationMonoFix(System.Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
- {
- bool isOk = true;
- if (sslPolicyErrors == SslPolicyErrors.None)
- {
- return true;
- }
- foreach (X509ChainStatus status in chain.ChainStatus)
- {
- if (status.Status == X509ChainStatusFlags.RevocationStatusUnknown)
- {
- continue;
- }
- chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain;
- chain.ChainPolicy.RevocationMode = X509RevocationMode.Online;
- chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 1, 0);
- chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags;
- bool chainIsValid = chain.Build((X509Certificate2)certificate);
- if (!chainIsValid)
- {
- isOk = false;
- }
- }
- return isOk;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement