Skip to content

Instantly share code, notes, and snippets.

View Benedicht's full-sized avatar
🏠
Working from home

Tivadar György Nagy Benedicht

🏠
Working from home
View GitHub Profile
public class CustomTLSClientSetup : MonoBehaviour
{
private void Start()
{
// 1. Add pinning only to selected host(s)
var hostName = "my.server.com";
(HTTPManager.PerHostSettings.Get(hostName, false) ?? HTTPManager.PerHostSettings.AddDefault(hostName))
.TLSSettings.BouncyCastleSettings.TlsClientFactory = PinningTlsClientFactory;
}
var Lib_BEST_HTTP_WebGL_WS_Bridge =
{
$ws: {
webSocketInstances: {},
nextInstanceId : 1,
halt: false,
/*UTF8Decoder: new TextDecoder('utf8'),*/
Set : function(socket) {
ws.webSocketInstances[ws.nextInstanceId] = socket;
#if !BESTHTTP_DISABLE_SIGNALR_CORE
using System.Threading;
#if CSHARP_7_OR_LATER
using System.Threading.Tasks;
#endif
using BestHTTP.Futures;
using BestHTTP.SignalRCore.Authentication;
using BestHTTP.SignalRCore.Messages;
#if !BESTHTTP_DISABLE_SIGNALR_CORE
using System.Threading;
#if CSHARP_7_OR_LATER
using System.Threading.Tasks;
#endif
using BestHTTP.Futures;
using BestHTTP.SignalRCore.Authentication;
using BestHTTP.SignalRCore.Messages;
@Benedicht
Benedicht / JsonDotNetParser.cs
Created November 21, 2022 10:38
Best HTTP/2 Socket.IO 3+ parser using Newtonsoft's Json
#if !BESTHTTP_DISABLE_SOCKETIO
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BestHTTP.PlatformSupport.Memory;
using BestHTTP.SocketIO3.Events;
using Newtonsoft.Json;
BlockingRequestHelper blkRequest = new BlockingRequestHelper();
var request = new HTTPRequest(new Uri("https://httpbin.org"), (req, resp) =>
{
switch (req.State)
{
// The request finished without any problem.
case HTTPRequestStates.Finished:
if (resp.IsSuccess)
{
@Benedicht
Benedicht / BestHTTP - BlockingRequestHelper.cs
Last active August 29, 2015 14:18
Helper class to be able send a blocking HTTPRequest - BestHTTP(http://u3d.as/5sb)
/// <summary>
/// Helper class to be able send a blocking HTTPRequest
/// </summary>
public sealed class BlockingRequestHelper
{
#region Private Fields
/// <summary>
/// AutResetEvent to wait for the request
/// </summary>
using System;
using System.Collections.Generic;
using UnityEngine;
using BestHTTP;
using System.IO;
public class LeaderboardTest : MonoBehaviour
{
const int count = 10;
@Benedicht
Benedicht / DownloadStreamingTestScript.cs
Created August 17, 2013 14:22
Streaming audio from the internet demo for BestHTTP Unity3D plugin.
using System;
using UnityEngine;
using System.Collections;
using System.IO;
using System.Collections.Generic;
using BestHTTP;
using BestHTTP.Caching;
[RequireComponent(typeof(AudioSource))]
@Benedicht
Benedicht / LoadImageTestScript.cs
Created August 17, 2013 14:19
Texture download demo for BestHTTP Unity3D plugin.
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(GUITexture))]
public class LoadImageTestScript : MonoBehaviour {
/// <summary>
/// Default url that points to an image somewhere on the internet.
/// </summary>
public string ImageUrl = "http://1.bp.blogspot.com/_EmX0HOnldCg/TODtaqLAHeI/AAAAAAAABnM/fLPKmMD66ng/s1600/funnycat.jpg";