Skip to content

Instantly share code, notes, and snippets.

@JohnTube
JohnTube / PlayFabCloudScript.js
Last active January 5, 2025 06:59
Photon custom authentication done in PlayFab in a special way to make use of Data and AuthCookie features but also allow/block list AppVersions.
// custom auth endpoint: https://{PlayFabTitleId}.playfablogic.com/webhook/1/prod/{PhotonSecretKey}/CustomAuth
// you can replace CustomAuth handler name and also in the URL
// C# client snippet:
// AuthenticationValues authValues = new AuthenticationValues();
// authValues.AuthType = CustomAuthenticationType.Custom;
// Dictionary<string, object> data = new Dictionary<string, object>(6);
// data["UserId"] = userId; // PlayFabId
// data["AppId"] = appId; // Photon AppId
// data["AppVersion"] = appVersion // Photon AppVersion
// data["Ticket"] = ticket; // PlayFab auth session ticket
@JohnTube
JohnTube / InternetWatchdog.cs
Last active September 9, 2020 16:54
A Unity behaviour that helps detecting when internet connection is available or lost and notifies you via event if this changes. This works with captive portals.
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
[DisallowMultipleComponent]
public class InternetWatchdog : MonoBehaviour
{
[SerializeField]
private float CheckTimer = 60f;
private float timer;
@JohnTube
JohnTube / Global.asax.cs
Last active April 3, 2019 13:49 — forked from AniAko/gist:3f955b5ad9a71f17635e
ASP.Net MVC: Do Not Allow URL to end in trailing slash without URL rewrite and without going to controller
// Put this in Global.asax.cs
// Do Not Allow URL to end in trailing slash
protected void Application_BeginRequest(object sender, EventArgs e)
{
string url = HttpContext.Current.Request.Url.AbsolutePath;
if (string.IsNullOrEmpty(url))
{
return;
}
@JohnTube
JohnTube / PhotonWebhooksArgs.js
Last active September 1, 2015 14:33
[Deprecated] Draft of PlayFab's CloudScript for Webhooks v1.0
// GameCreate webhook
handlers.RoomCreated = function(args){
/** Common/shared args between all the (6) webhooks **/
var appId = args.AppId,
appVersion = args.AppVersion,
region = args.Region,
gameId = args.GameId,
type = args.Type, // type could be "Load" when rejoining or "Create"
actorNr = args.ActorNr,
/** Common/shared args between all the (6) webhooks **/