Created
September 13, 2015 07:53
-
-
Save gleitz/57176f953d165e6c4fd3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
using Meteor; | |
using Extensions; | |
public class MeteorUpdate : MonoBehaviour { | |
public string meteorURL = "wss://calder.meteor.com/websocket"; | |
void Start () { | |
Debug.Log ("starting!"); | |
Meteor.Connection.Logging = true; | |
Security.PrefetchSocketPolicy("calder.meteor.com", 443); | |
StartCoroutine(MeteorExample()); | |
} | |
void Update () { | |
} | |
IEnumerator MeteorExample() { | |
Debug.Log ("connecting!"); | |
yield return Meteor.Connection.Connect (meteorURL); | |
Debug.Log (Meteor.Connection.Connected.ToString()); | |
// Login | |
yield return Meteor.Accounts.LoginAsGuest (); | |
Debug.Log ("logged in!"); | |
var collection = Collection<MeteorMap>.Create ("spheres"); | |
var subscription = Meteor.Subscription.Subscribe("spheres"); | |
collection.DidAddRecord += (arg1, doc) => { | |
Debug.Log ("id: " + doc._id); | |
Debug.Log (doc.sphereUrl); | |
}; | |
collection.DidChangeRecord += (arg1, doc, arg3, arg4) => { | |
Debug.Log ("id: " + doc._id); | |
Debug.Log (doc.sphereUrl); | |
}; | |
yield return (Coroutine)subscription; | |
} | |
} | |
public class MeteorMap : Meteor.MongoDocument { | |
public string sphereUrl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment