static void Main(string [] args) { _client = new DdpConnection("localhost:3000"); _client.Retry = true; _client.Login += Login; _client.Connected += OnConnected; _client.Connect(); Console.ReadKey(); _client.Close(); }
public void Update() { if (Input.GetKeyDown(KeyCode.C)) { Debug.Log("Connecting ..."); ddpConnection.Connect(); } if (Input.GetKeyDown(KeyCode.V)) { Debug.Log("Closing connection ..."); ddpConnection.Close(); } if (Input.GetKeyDown(KeyCode.S)) { friendSub = ddpConnection.Subscribe("friends"); friendSub.OnReady = (Subscription obj) => { Debug.Log("Ready subscription: " + obj.id); }; } if (Input.GetKeyDown(KeyCode.U)) { ddpConnection.Unsubscribe(friendSub); } if (Input.GetKeyDown(KeyCode.R)) { ddpConnection.Call("friends.removeAll"); } if (Input.GetKeyDown(KeyCode.F)) { MethodCall methodCall = ddpConnection.Call("friends.create", JSONObject.CreateStringObject("Coco")); methodCall.OnUpdated = (MethodCall obj) => { Debug.Log("Updated, methodId=" + obj.id); }; methodCall.OnResult = (MethodCall obj) => { Debug.Log("Result = " + obj.result); }; } if (Input.GetKeyDown(KeyCode.A)) { MethodCall methodCall = ddpConnection.Call("friends.add", JSONObject.Create(7), JSONObject.Create(5)); methodCall.OnUpdated = (MethodCall obj) => { Debug.Log("Updated, methodId=" + obj.id); }; methodCall.OnResult = (MethodCall obj) => { Debug.Log("Result = " + obj.result); }; } }
private static void Main(string[] args) { _client = new DdpConnection(); _client.Login += OnLogin; _client.Closed += OnClose; _client.Error += OnError; _client.Connected += OnConnected; _client.Connect("localhost:3000"); Console.ReadKey(); _client.Close(); }
public void Update() { if (Input.GetKeyDown(KeyCode.C)) { Debug.Log("Connecting ..."); ddpConnection.Connect(); } if (Input.GetKeyDown(KeyCode.V)) { ddpConnection.Close(); } if (Input.GetKeyDown(KeyCode.U)) { StartCoroutine(account.CreateUserAndLogin(username, password)); } if (Input.GetKeyDown(KeyCode.L)) { StartCoroutine(account.Login(username, password)); } if (Input.GetKeyDown(KeyCode.R)) { StartCoroutine(account.ResumeSession(token)); } if (Input.GetKeyDown(KeyCode.T)) { Debug.Log("Token " + account.token + " expires at " + account.tokenExpiration); } if (Input.GetKeyDown(KeyCode.O)) { StartCoroutine(account.Logout()); } }
public void Update() { if (Input.GetKeyDown(KeyCode.C)) { Debug.Log("Connecting ..."); ddpConnection.Connect(); } if (Input.GetKeyDown(KeyCode.V)) { ddpConnection.Close(); } if (Input.GetKeyDown(KeyCode.S)) { friendSub = ddpConnection.Subscribe("friends"); friendSub.OnReady = (Subscription obj) => { Debug.Log("Ready subscription: " + obj.id); }; } if (Input.GetKeyDown(KeyCode.U)) { ddpConnection.Unsubscribe(friendSub); } if (Input.GetKeyDown(KeyCode.R)) { ddpConnection.Call("friends.removeAll"); } if (Input.GetKeyDown(KeyCode.F)) { ddpConnection.Call("friends.create", JSONObject.CreateStringObject("Coco")); } if (Input.GetKeyDown(KeyCode.D)) { foreach (var entry in friendCollection.documents) { Debug.Log(entry.Key + " " + entry.Value); } } if (Input.GetKeyDown(KeyCode.O)) { JSONObject parents = new JSONObject(); parents.AddField("mother", "wonder woman"); parents.AddField("father", "batman"); JSONObject attr = new JSONObject(); attr.AddField("age", 24); attr.AddField("height", 180); attr.AddField("parents", parents); ddpConnection.Call("friends.addAttributes", JSONObject.StringObject("Coco"), attr); } if (Input.GetKeyDown(KeyCode.P)) { JSONObject attr = new JSONObject(); attr.AddField("age", 1); attr.AddField("height", 1); attr.AddField("parents.mother", 1); ddpConnection.Call("friends.removeAttributes", JSONObject.StringObject("Coco"), attr); } }